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 |
这是怎么回事?我觉得我的算法很好的啊?为什么总是WA呢?请高手指点!!#include <iostream> #include <algorithm> using namespace std; #define MAXNUM 110 void main() { int m, n; char a[MAXNUM][MAXNUM] = {0}; char j; int i, number, k, x; cin>>n>>m; while(cin>>i>>j) { a[i - 1][strlen(a[i - 1])] = j; } for(k = 0; k < n; k++) { sort(a[k], a[k] + strlen(a[k])); } for(k = 0; k < n; k++) { if(!a[k][0] || a[k][0] == 's') continue; for(x = k + 1; x < n; x++) if(!strcmp(a[k], a[x])) { a[x][0] = 's'; } } number = 0; for(k = 0; k < n; k++) { if(a[k][0] && a[k][0] != 's') number++; } cout<<number<<endl; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator