#include<iostream>
#include<string.h>
#include<string>
#include<vector>
#include<iterator>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<functional>
#include<cmath>
using namespace std;
#define NM 100000
int nm[NM][2];
int N, M;
vector< pair<int, int> > diff;
bool cacus()
{
for(size_t i=0; i<diff.size(); i++)
{
for(size_t j=i+1; j<diff.size(); j++)
{
int index_i = diff[i].second;
int index_j = diff[j].second;
if(nm[index_i][0] == nm[index_j][1] || nm[index_i][1] == nm[index_j][0])
return true;
}
}
return false;
}
void test()
{
int result=0;
cin >> N >> M;
for(int i=0; i<M; i++)
{
cin >> nm[i][0] >> nm[i][1];
if(abs(nm[i][0]-nm[i][1]) > 1)
diff.push_back(make_pair(nm[i][0]-nm[i][1], i));
}
if(cacus())
cout << "Not cactus" << endl;
else
cout << "Cactus" << endl;
}
int main()
{
test();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2452 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |