# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
442806 | 2021-07-09T07:35:49 Z | sstefanovic | Trobojnica (COCI19_trobojnica) | C++17 | 1 ms | 204 KB |
#include<bits/stdc++.h> using namespace std; const int MAXN = 2e5+10; int n; string s; int slj[MAXN], boje[MAXN], cnt[3], solx[MAXN], soly[MAXN], solb[MAXN]; int main( ){ cin >> n >> s; for (int i=0; i<n; i++){ boje[i]=s[i]-'1'; cnt[boje[i]]++; slj[i] = (i+1)%n; } int x=0; for (int i=0; i<n-3; i++){ if (max (cnt[0], max(cnt[1], cnt[2])) == n-i){ cout << "NE\n"; return 0; } while (boje[x] == boje [slj[x]] or cnt[boje[x]] == 1 && cnt[boje[slj[x]]]){ x = slj[x]; } int y = slj [x]; int nX = 3-boje[x]-boje[y]; cnt[boje[x]]--; cnt[boje[y]]--; cnt[nX]++; solx[i]=x; soly[i]=slj[y]; solb[i]=nX; boje[x] = nX; slj[x]=slj[y]; } if (cnt[0] == 1 && cnt[1]==1 && cnt[2] == 1){ cout << "DA\n"; for (int i=0; i<n-3; i++){ cout << solx[i] << " " << soly[i] <<" " << solb[i] << endl; } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Integer parameter [name=X] equals to 0, violates the range [1, 8] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Integer parameter [name=X] equals to 0, violates the range [1, 8] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Integer parameter [name=X] equals to 0, violates the range [1, 8] |
2 | Halted | 0 ms | 0 KB | - |