Submission #442880

#TimeUsernameProblemLanguageResultExecution timeMemory
442880Markomafko972Trobojnica (COCI19_trobojnica)C++14
0 / 110
1 ms204 KiB
#include <bits/stdc++.h> #define X first #define Y second using namespace std; int n, da; char c; set< pair< pair<int, int>, int > > s; set< pair< pair<int, int>, int > > :: iterator it; set< pair< pair<int, int>, int > > :: iterator it2; vector< pair< pair<int, int>, int > > sol; int main () { cin >> n; for (int i = 0; i < n; i++) { cin >> c; s.insert({{i, (i+1)%n}, c-'1'}); } while (s.size() > 2) { da = 0; for (it = s.begin(); it != s.end(); it=it) { //cout << (*it).X.X << " " << (*it).X.Y << " " << (*it).Y << endl; it2 = it; it2++; if (it2 != s.end()) { if ((*it).Y != (*it2).Y) { da = 1; int poc = (*it).X.X; int kr = (*it2).X.Y; int br = 3-(*it).Y-(*it2).Y; s.erase(it2); it2 = it; it++; s.erase(it2); s.insert({{poc, kr}, br}); sol.push_back({{poc+1, kr+1}, br+1}); } else { it++; } } else { it++; } } if (da == 0) break; } if (!da) { cout << "NE"; return 0; } it = s.begin(); it2 = s.begin(); it2++; if ((*it).Y != (*it2).Y) { cout << "NE"; return 0; } cout << "DA\n"; for (int i = 0; i < (int)sol.size()-1; i++) cout << sol[i].X.X << " " << sol[i].X.Y << " " << sol[i].Y << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...