Submission #1154427

#TimeUsernameProblemLanguageResultExecution timeMemory
1154427hmm789Trobojnica (COCI19_trobojnica)C++20
110 / 110
26 ms6864 KiB
#include "bits/stdc++.h" using namespace std; #define int long long #define double long double #define INF 1000000000000000000 #define MOD 1000000007 int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; string s; cin >> n >> s; int clr[n], nxt[n], cnt[4], xr = 0, x = 0; bool f = true; memset(cnt, 0, sizeof(cnt)); for(int i = 0; i < n; i++) { clr[i] = s[i]-'0'; cnt[clr[i]]++; xr ^= clr[i]; if(clr[i] != clr[0]) f = false; nxt[i] = (i+1)%n; } if(xr || f) { cout << "NE\n"; return 0; } cout << "DA\n"; for(int i = 0; i < n-3; i++) { while(clr[x] == clr[nxt[x]] || (cnt[clr[x]] == 1 && cnt[clr[nxt[x]]] == 1)) x = nxt[x]; int nclr = clr[x]^clr[nxt[x]]; cout << x+1 << " " << nxt[nxt[x]]+1 << " " << nclr << '\n'; cnt[clr[x]]--; cnt[clr[nxt[x]]]--; cnt[nclr]++; nxt[x] = nxt[nxt[x]]; clr[x] = nclr; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...