Submission #711788

#TimeUsernameProblemLanguageResultExecution timeMemory
711788pccSlagalica (COCI19_slagalica2)C++14
70 / 70
38 ms7992 KiB
#include <bits/stdc++.h> using namespace std; #define pii pair<int,int> #define fs first #define sc second vector<int> v[9]; int deg[9]; pii dif[] = {{0,0},{-1,1},{-1,-1},{1,1},{1,-1},{-2,1},{-2,-1},{-1,2},{1,2}}; vector<int> ans; const int mxn = 1e5+10; bitset<mxn> vis; struct Edge{ int to,val,id; Edge(){} Edge(int tt,int vv,int ii){ id = ii; to = tt; val = vv; } bool operator<(Edge &b){ return val<b.val; } }; vector<Edge> paths[9]; int ptr[9]; void dfs(int now){ while(!paths[now].empty()){ auto nxt = paths[now].back().to,val = paths[now].back().val; paths[now].pop_back(); dfs(nxt); ans.push_back(val); } return; } int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int n; cin>>n; for(int i = 0;i<n;i++){ int a,b; cin>>a>>b; paths[dif[a].fs+4].push_back(Edge(dif[a].sc+4,b,i)); deg[dif[a].sc+4]++; deg[dif[a].fs+4]--; } if(paths[2].size()!=1||deg[6] != 1){ cout<<"-1"; return 0; } // paths[6].push_back({2,0}); for(int i = 3;i<=5;i++){ if(deg[i] != 0){ cout<<-1; return 0; } } for(auto &i:paths)sort(i.rbegin(),i.rend()); dfs(2); while(!ans.empty())cout<<ans.back()<<' ',ans.pop_back();return 0; }

Compilation message (stderr)

slagalica.cpp: In function 'int main()':
slagalica.cpp:60:5: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   60 |     while(!ans.empty())cout<<ans.back()<<' ',ans.pop_back();return 0;
      |     ^~~~~
slagalica.cpp:60:61: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   60 |     while(!ans.empty())cout<<ans.back()<<' ',ans.pop_back();return 0;
      |                                                             ^~~~~~
#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...