| ||||||||||
| 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?我的想法是把人看到的树放在一起,然后对这些树排序,再比较各个人看到的树的集合。相等一对就减掉1。
#include <iostream.h>
#include <string.h>
#define MAXNUM 100
void main()
{
int m, n;
char a[MAXNUM][MAXNUM] = {0};
char i, j, t;
int number, k, x, y, tt;
cin>>n>>m;
number = n;
while(cin>>i>>j)
{
a[i - 1 - 48][strlen(a[i - 1 - 48])] = j;
}
for(k = 0; k < m; k++)
{
for(x = 0; x < strlen(a[k]); x++)
{
t = a[k][x];
tt = x;
for(y = x + 1; y < strlen(a[k]); y++)
{
if(a[k][y] < t)
{
t = a[k][y];
tt = y;
}
}
a[k][tt] = a[k][x];
a[k][x] = t;
}
}
for(k = 0; k < m; k++)
for(x = k + 1; x < m; x++)
if(!strcmp(a[k], a[x]))
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