# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
211120 | 2020-03-19T09:11:34 Z | Aldas25 | Trobojnica (COCI19_trobojnica) | C++14 | 5 ms | 384 KB |
#include <bits/stdc++.h> using namespace std; #define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr) #define FOR(i, a, b) for(int i = (a); i <= (b); i++) #define REP(n) FOR(O, 1, (n)) #define pb push_back #define f first #define s second typedef long double ld; typedef long long ll; typedef pair<int, int> pii; typedef pair<int, pii> piii; typedef vector<int> vi; typedef vector<pii> vii; typedef vector<ll> vl; typedef vector<piii> viii; const int MAXN = 500100, MAXK = 60; const ll MOD = 1e9+7; const int INF = 1e8; const ld PI = asin(1) * 2; void setIO () { FAST_IO; } void setIO (string s) { setIO(); freopen((s+".in").c_str(),"r",stdin); freopen((s+".out").c_str(),"w",stdout); } int n; deque<pair<int, pii>> q; vector<pair<pii, int>> ans; int main() { setIO(); cin >> n; FOR(i, 1, n) { int next = i+1; if (next > n) next = 1; char c; cin >> c; q.push_back({(c-'0'), {i, next}}); } while (q.size() > 3) { auto cur = q.front(); q.pop_front(); if (q.front().f != cur.f) { int c = 1; FOR(i, 1, 3) { if (i != q.front().f && i != cur.f) c = i; } ans.pb({{cur.s.f, q.front().s.s}, c}); q.pop_front(); q.push_front({c, {cur.s.f, q.front().s.s}}); } else if (q.back().f != cur.f) { int c = 1; FOR(i, 1, 3) { if (i != q.front().f && i != cur.f) c = i; } ans.pb({{q.back().s.f, cur.s.s}, c}); q.pop_back(); q.push_back({c, {q.back().s.f, cur.s.s}}); } else { cout << "NE"; return 0; } } vi cols; while (!q.empty()) {cols.pb(q.front().f); q.pop_front();} FOR(i, 0, cols.size()-1) { if (cols[i] == cols[(i+1)%((int)cols.size())]) { cout << "NE"; return 0; } } cout << "DA\n"; for (auto p : ans) cout << p.f.f << " " << p.f.s << " " << p.s << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |