Submission #258914

#TimeUsernameProblemLanguageResultExecution timeMemory
258914itiamSlagalica (COCI19_slagalica2)C++11
0 / 70
1099 ms2672 KiB
#include <bits/stdc++.h> using namespace std; #define parii pair<int,int> #define pb push_back int n,rj[100007]; int l[8]={1,1,-1,-1,0,0,1,-1},d[8]={1,-1,1,-1,1,-1,0,0}; vector<parii> v; int main(){ int mog=0,lr=0,dr=0; cin >> n; for (int i=0;i<n;i++){ int a,b; cin >> a >> b; if (a==5 || a==6){ if (lr!=0){ cout << -1; return 0;} lr=a;rj[0]=b;mog+=l[a-1]+d[a-1]; } else if (a==7 || a==8){ if (dr!=0){ cout << -1; return 0;} dr=a;rj[n-1]=b;mog+=l[a-1]+d[a-1]; } else{ mog+=l[a-1]+d[a-1]; v.pb({b,a}); } } if (mog!=0){ cout << -1; return 0;} sort(v.begin(),v.end()); int tmp=-1*d[lr-1],z=-1*l[dr-1],br=1; while(v.size()!=1){ for (int i=0;i<v.size();i++){ int sl=v[i].second; if (l[sl-1]==tmp){ tmp=-1*d[sl-1]; rj[br]=v[i].first; br+=1; v.erase(v.begin()+i); break; } } } rj[n-2]=v[0].first; for (int i=0;i<n;i++){ if(i!=0) cout << " "; cout << rj[i]; } return 0; }

Compilation message (stderr)

slagalica.cpp: In function 'int main()':
slagalica.cpp:35:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i=0;i<v.size();i++){
                      ~^~~~~~~~~
slagalica.cpp:32:24: warning: unused variable 'z' [-Wunused-variable]
     int tmp=-1*d[lr-1],z=-1*l[dr-1],br=1;
                        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...