Submission #667566

#TimeUsernameProblemLanguageResultExecution timeMemory
667566berrRoads (CEOI20_roads)C++17
0 / 100
2 ms2644 KiB
#include <bits/stdc++.h> using namespace std; const int N=1e5+37; //1.st subtask all are vertical vector<array<int, 2>> a[N]; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin>>n; vector<array<int, 2>> node(2*n+1); vector<int> x, y; map<int, int> cx, cy; for(int i=1; i<=n*2; i+=2) { cin>>node[i][0]>>node[i][1]; cin>>node[i+1][0]>>node[i+1][1]; x.push_back(node[i][0]); x.push_back(node[i+1][0]); y.push_back(node[i][1]); y.push_back(node[i+1][1]); } sort(x.begin(), x.end()); sort(y.begin(), y.end()); int cnt=1; for(auto i: x) { if(!cx.count(i)) cx[i]=cnt, cnt++; } cnt=1; for(auto i: y) { if(!cy.count(i)) cy[i]=cnt; cnt++; } for(int i=1; i<=2*n; i++) { a[cy[node[i][1]]].push_back({cx[node[i][0]], i}); } for(int i=0; i<N; i++) { if(a[i].size()) { sort(a[i].begin(), a[i].end()); } } for(int i=1; i<N; i++) { if(a[i].size()) for(int l=1; l<a[i].size()-1; l+=2) { int v=a[i][l][1]; int u=a[i][l+1][1]; cout<<node[v][0]<<" "<<node[v][1]<<" "; cout<<node[u][0]<<" "<<node[u][1]<<"\n"; } if(!a[i+1].size()) break; int v=a[i][0][1]; int u=a[i+1][0][1]; cout<<node[v][0]<<" "<<node[v][1]<<" "; cout<<node[u][0]<<" "<<node[u][1]<<"\n"; } }

Compilation message (stderr)

roads.cpp: In function 'int main()':
roads.cpp:42:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   42 |         if(!cy.count(i)) cy[i]=cnt; cnt++;
      |         ^~
roads.cpp:42:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   42 |         if(!cy.count(i)) cy[i]=cnt; cnt++;
      |                                     ^~~
roads.cpp:62:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         for(int l=1; l<a[i].size()-1; l+=2)
      |                      ~^~~~~~~~~~~~~~
#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...