Submission #970301

#TimeUsernameProblemLanguageResultExecution timeMemory
970301mychecksedadFountain Parks (IOI21_parks)C++17
5 / 100
100 ms17796 KiB
#include "parks.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n'; #define ll long long int const int N = 3e5+10; int construct_roads(std::vector<int> x, std::vector<int> y) { if (x.size() == 1) { build({}, {}, {}, {}); return 1; } int n = x.size(); vector<int> u, v, a, b; vector<pair<int, int>> L, R; for(int i = 0; i < n; ++i){ if(x[i] == 2) L.pb({y[i], i}); else R.pb({y[i], i}); } sort(all(L)); sort(all(R)); for(int i = 0; i + 1 < L.size(); ++i){ if(L[i + 1].first - L[i].first > 2){ return 0; } u.pb(L[i].second); v.pb(L[i + 1].second); a.pb(1); b.pb(L[i + 1].first + L[i].first>>1); } for(int i = 0; i + 1 < R.size(); ++i){ if(R[i + 1].first - R[i].first > 2){ return 0; } u.pb(R[i].second); v.pb(R[i + 1].second); a.pb(5); b.pb(R[i + 1].first + R[i].first>>1); } if(!R.empty() && !L.empty()){ if(L[0].first > R.back().first) return 0; if(R[0].first > L.back().first) return 0; if(R[0].first > L[0].first) L.swap(R); for(int i = 0; i < R.size(); ++i){ if(R[i].first == L[0].first){ u.pb(R[i].second); v.pb(L[0].second); a.pb(3); b.pb(R[i].first - 1); break; } } } build(u, v, a, b); return 1; }

Compilation message (stderr)

parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:27:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i = 0; i + 1 < L.size(); ++i){
      |                    ~~~~~~^~~~~~~~~~
parks.cpp:34:29: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   34 |         b.pb(L[i + 1].first + L[i].first>>1);
parks.cpp:36:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i = 0; i + 1 < R.size(); ++i){
      |                    ~~~~~~^~~~~~~~~~
parks.cpp:43:29: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   43 |         b.pb(R[i + 1].first + R[i].first>>1);
parks.cpp:50:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         for(int i = 0; i < R.size(); ++i){
      |                        ~~^~~~~~~~~~
#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...