WA for 10227 - Forests
Posted: Fri Jun 01, 2012 12:45 pm
hi...
I've coded this question but it's got WA...
here's my code:
is there anyone to help me to got ACC?
tnx
I've coded this question but it's got WA...
here's my code:
Code: Select all
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
int main()
{
//freopen ("10227.in", "r", stdin);
int t;
cin >> t;
string str;
getline (cin, str);
getline (cin, str);
int P, T;
int x, y;
for (int i = 0; i < t && cin >> P >> T; i++)
{
vector < vector <int> > v (101);
set <string> s;
getline (cin, str);
while (getline (cin, str) && str != "")
{
stringstream ss (str);
ss >> x; ss >> y;
if (x > 0 && y > 0)
v[x].push_back (y);
}
for (int j = 1; j <= P; j++)
sort (v[j].begin(), v[j].end());
for (int j = 1; j <= P; j++)
{
stringstream ss;
for (int k = 0; k < v[j].size(); k++)
ss << v[j][k];
s.insert (ss.str());
}
cout << s.size() << endl;
if (i != t-1)
cout << endl;
}
return 0;
}
tnx