# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
448705 | Antekb | Trobojnica (COCI19_trobojnica) | C++14 | 77 ms | 7392 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define st first
#define nd second
using namespace std;
int main(){
int n;
cin>>n;
vector<int> V(n);
vector<pair<int, int> > co(n);
for(int i=0; i<n; i++)co[i].st=i+1, co[i].nd=(i+1)%n+1;
string s;
cin>>s;
int ile[3]={0, 0, 0};
for(int i=0; i<n; i++)V[i]=s[i]-'1', ile[V[i]]++;
if((ile[0]&1)!=(n&1) || (ile[1]&1)!=(n&1) || max({ile[0], ile[1], ile[2]})==n){
cout<<"NE";
return 0;
}
for(int i=0; i<3; ++i)ile[i]=(n-2-ile[i])/2;
cout<<"DA\n";
for(int i=0; i<V.size()-3; i++){
if(V[i]==V[i+1]){
V.push_back(V[i]);
co.push_back(co[i]);
}
else if(ile[3-V[i]-V[i+1]]!=0){
cout<<co[i].st<<" "<<co[i+1].nd<<" "<<4-V[i]-V[i+1]<<"\n";
co[i+1].st=co[i].st;
V[i+1]=3-V[i]-V[i+1];
ile[V[i+1]]--;
}
else{
V.push_back(V[i]);
co.push_back(co[i]);
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |