Submission #1079055

#TimeUsernameProblemLanguageResultExecution timeMemory
1079055raphaelpTiles (BOI24_tiles)C++14
13 / 100
119 ms14528 KiB
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<vector<int>> Tab; vector<int> X(N), Y(N); for (int i = 0; i < N; i++) { cin >> X[i] >> Y[i]; } for (int i = 0; i < N; i++) { if (X[(i + 1) % N] == X[i]) { if (Y[i] < Y[(i + 1) % N]) Tab.push_back({X[i], min(Y[i], Y[(i + 1) % N]), max(Y[i], Y[(i + 1) % N]) - 1, 1}); else Tab.push_back({X[i], min(Y[i], Y[(i + 1) % N]), max(Y[i], Y[(i + 1) % N]) - 1, -1}); } } sort(Tab.begin(), Tab.end()); if (Tab[0][3] == -1) for (int i = 0; i < Tab.size(); i++) Tab[i][3] = 0 - Tab[i][3]; int last = -1; int impair = 0; vector<int> mod12(2); int maxx = 0; set<vector<int>> S; for (int i = 0; i < Tab.size(); i++) { if (Tab[i][0] != last || i == Tab[i].size() - 1) { last = Tab[i][0]; if (impair) break; if (mod12[0] && mod12[1]) continue; int par = ((mod12[1]) ? 1 : 0); maxx = ((Tab[i][0] % 2 == par) ? Tab[i][0] : (Tab[i][0] - 1)); } if (Tab[i][3] == 1) { auto pos = S.lower_bound({Tab[i][1]}); if (pos != S.end() && (*pos)[0] == Tab[i][2] + 1 && (*pos)[2] == Tab[i][0] % 2) { Tab[i][2] = (*pos)[1]; if (((*pos)[1] - (*pos)[0] + 1) % 2 == 1) impair--; mod12[(*pos)[2]]--; pos = S.erase(pos); } if (pos != S.begin()) { pos--; if ((*pos)[1] == Tab[i][1] - 1 && (*pos)[2] == Tab[i][0] % 2) { Tab[i][1] = (*pos)[0]; if (((*pos)[1] - (*pos)[0] + 1) % 2 == 1) impair--; mod12[(*pos)[2]]--; S.erase(pos); } } if ((Tab[i][2] - Tab[i][1] + 1) % 2 == 1) impair++; mod12[Tab[i][0] % 2]++; S.insert({Tab[i][1], Tab[i][2], Tab[i][0] % 2}); } else { auto pos = S.upper_bound({Tab[i][2]}); pos--; if (Tab[i][0] % 2 != (*pos)[2]) break; if (Tab[i][1] < (*pos)[0]) break; int left = (*pos)[0], right = Tab[i][1] - 1; if (right >= left) { mod12[(*pos)[2]]++; if ((right - left) % 2 == 0) impair++; S.insert({left, right, (*pos)[2]}); } left = Tab[i][2] + 1, right = (*pos)[1]; if (right >= left) { mod12[(*pos)[2]]++; if ((right - left) % 2 == 0) impair++; S.insert({left, right, (*pos)[2]}); } mod12[(*pos)[2]]--; if (((*pos)[1] - (*pos)[0]) % 2 == 0) impair--; } } cout << maxx; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:25:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for (int i = 0; i < Tab.size(); i++)
      |                         ~~^~~~~~~~~~~~
Main.cpp:32:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int i = 0; i < Tab.size(); i++)
      |                     ~~^~~~~~~~~~~~
Main.cpp:34:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         if (Tab[i][0] != last || i == Tab[i].size() - 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...