Submission #448705

#TimeUsernameProblemLanguageResultExecution timeMemory
448705AntekbTrobojnica (COCI19_trobojnica)C++14
110 / 110
77 ms7392 KiB
#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)

trobojnica.cpp: In function 'int main()':
trobojnica.cpp:21:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for(int i=0; i<V.size()-3; i++){
      |               ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...