Submission #4166

#TimeUsernameProblemLanguageResultExecution timeMemory
4166gudbooyCactus? Not cactus? (kriii1_C)C++98
0 / 1
0 ms2452 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...