# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
4151 | gudbooy | Cactus? Not cactus? (kriii1_C) | C++98 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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(int i=0; i<diff.size(); i++)
{
for(int 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;
}