Submission #1063211

#TimeUsernameProblemLanguageResultExecution timeMemory
1063211j_vdd16Fountain Parks (IOI21_parks)C++17
0 / 100
0 ms348 KiB
#include "parks.h" #include <algorithm> #include <bitset> #include <cstdint> #include <cstring> #include <iostream> #include <limits.h> #include <math.h> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> //#define int long long #define loop(X, N) for(int X = 0; X < (N); X++) #define all(V) V.begin(), V.end() #define rall(V) V.rbegin(), V.rend() using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<vector<ii>> vvii; typedef vector<bool> vb; typedef vector<vector<bool>> vvb; int construct_roads(std::vector<int> xs, std::vector<int> ys) { int n = xs.size(); map<int, ii> benches; loop(i, n) { if (benches.count(ys[i]) == 0) { benches[ys[i]] = { -1, -1 }; } if (xs[i] == 2) { benches[ys[i]].first = i; } if (xs[i] == 4) { benches[ys[i]].second = i; } } int m = n - 1; vi u, v, a, b; bool prevLeft = false, prevRight = false; int prevY = 0; for (auto [y, p] : benches) { if (y - prevY > 2 && prevY > 0) { return 0; } bool left = p.first != -1; bool right = p.second != -1; if (left && prevLeft) { u.push_back(p.first); v.push_back(benches[y - 2].first); a.push_back(1); b.push_back(y - 1); } else if (right && prevRight) { u.push_back(p.second); v.push_back(benches[y - 2].second); a.push_back(5); b.push_back(y - 1); } else { return 0; } if (left && right) { u.push_back(p.first); v.push_back(p.second); a.push_back(3); b.push_back(y - 1); } prevY = y; prevLeft = left; prevRight = right; } 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:50:9: warning: unused variable 'm' [-Wunused-variable]
   50 |     int m = n - 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...