Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
floyd, 这么水的题为什么没人做?#include <iostream> #include <string> #include <vector> using namespace std; struct spam{ int T1, T2; string s1, s2, s3; int origin; }; int main() { while(1){ int N; cin >> N; if(N == 0) break; bool adj[23][23] = {0}; int adjNum[23] = {0}; //int adjList[23][23]; for(int i = 1; i <= N; i++){ while(1){ int temp; cin >> temp; if(temp == 0) break; //adjList[i][adjNum[i]] = temp; adjNum[i]++; adj[i][temp] = 1; } } vector<spam> vs; string name[23]; while(1){ spam temp; cin >> temp.origin; if(temp.origin == 0) break; cin >> temp.T1 >> temp.T2 >> temp.s1 >> temp.s2 >> temp.s3; vs.push_back(temp); } for(int i = 1; i <= N; i++) cin >> name[i]; int sz = vs.size(); bool conn[2][23][23]; for(int i = 1; i <= N; i++){ for(int j = 1; j <= N; j++){ if(i == j) conn[0][i][j] = 1; else conn[0][i][j] = adj[i][j]; } } for(int i = 1; i <= N; i++){ int from = (i+1)%2, to = i%2; for(int j = 1; j <= N; j++){ for(int k = 1; k <= N; k++){ if(conn[from][j][i] && conn[from][i][k]){ conn[to][j][k] = 1; } else{ conn[to][j][k] = conn[from][j][k]; } } } } int tar = N%2; for(int i = 1; i <= N; i++){ cout << name[i] << ":"; for(int j = 0; j < sz; j++){ spam temp = vs[j]; int val = (conn[tar][temp.origin][i]) ? adjNum[i] : 0; if(val < temp.T1) cout << " " << temp.s1; else if(val < temp.T2) cout << " " << temp.s2; else cout << " " << temp.s3; } cout << endl; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator