Submission #537846

#TimeUsernameProblemLanguageResultExecution timeMemory
537846Servus2022Trobojnica (COCI19_trobojnica)C++14
0 / 110
0 ms212 KiB
#include <bits/stdc++.h> using namespace std; struct muchie { int x,y,cul; }; vector <muchie> sol ; int n,i; int v[200005]; int ind (int x) { if (x<=0) { return x+n; } if (x>n) { return x-n; } return x; } int cenue(int a ,int b) { int i; for (i=1;i<=3;i++) { if (i!=a&&i!=b) { return i; } } } int main() { ios_base :: sync_with_stdio(false); cin.tie(0); #ifdef HOME ifstream cin("date.in"); ofstream cout("date.out"); #endif // HOME cin>>n; for (i=1;i<=n;i++) { char ch; cin>>ch; v[i]=ch-'0'; } for (int varf = 1 ;varf <=n; varf ++ ) { int acum,stanga,dreapta; if (v[ind(varf)]==v[ind(varf-1)]) { continue; } sol.clear(); sol.push_back(muchie{ind(varf-1),ind(varf+1),cenue(v[ind(varf-1)],v[ind(varf)])}); acum = cenue(v[ind(varf-1)],v[ind(varf)]); stanga = varf - 1; dreapta = varf + 1 ; while (ind(stanga-1)!=ind(dreapta+1)) { if (v[ind(stanga-1)]!=acum) { sol.push_back(muchie{ind(stanga-1),ind(dreapta),cenue(acum,v[ind(stanga-1)])}); acum = cenue(acum,v[ind(stanga-1)]); stanga--; } else if (v[ind(dreapta)]!=acum) { sol.push_back(muchie{ind(stanga),ind(dreapta+1),cenue(acum,v[ind(dreapta)])}); acum = cenue(acum,v[ind(dreapta)]); dreapta++; } else { break; } } if (v[ind(stanga-1)]==acum||acum==v[ind(dreapta)]||v[ind(stanga-1)]==v[ind(dreapta)]) { continue; } if (sol.size()==n-3) { cout<<"DA"<<'\n'; for (i=0;i<sol.size();i++) { cout<<sol[i].x<<" "<<sol[i].y<<" "<<sol[i].cul<<'\n'; } return 0; } } cout<<"NE"; return 0; }

Compilation message (stderr)

trobojnica.cpp: In function 'int main()':
trobojnica.cpp:85:23: warning: comparison of integer expressions of different signedness: 'std::vector<muchie>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   85 |         if (sol.size()==n-3)
      |             ~~~~~~~~~~^~~~~
trobojnica.cpp:88:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<muchie>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |             for (i=0;i<sol.size();i++)
      |                      ~^~~~~~~~~~~
trobojnica.cpp: In function 'int cenue(int, int)':
trobojnica.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
   33 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...