Submission #837934

#TimeUsernameProblemLanguageResultExecution timeMemory
837934FulopMateSeats (IOI18_seats)C++17
17 / 100
4070 ms55624 KiB
#include "seats.h" #include <bits/stdc++.h> using namespace std; int n; vector<pair<int,int>> v; vector<int> a, b, c, d; vector<bool> lehet; int ans; void give_initial_chart(int H, int W, vector<int> R, vector<int> C) { n = H*W; v.resize(n); a.resize(n); b.resize(n); c.resize(n); d.resize(n); lehet.resize(n); for(int i = 0; i < n; i++){ v[i] = {R[i], C[i]}; } int ca = v[0].first, cb = v[0].first, cc = v[0].second, cd = v[0].second; a[0] = ca, b[0] = cb, c[0] = cc, d[0] = cd; lehet[0] = 1; ans = 1; for(int i = 1; i < n; i++){ ca = min(ca, v[i].first); cb = max(cb, v[i].first); cc = min(cc, v[i].second); cd = max(cd, v[i].second); if(i+1 == (cb-ca+1)*(cd-cc+1)){ lehet[i] = true; ans++; } a[i] = ca, b[i] = cb, c[i] = cc, d[i] = cd; } } int swap_seats(int x, int y) { swap(v[x], v[y]); if(x > y)swap(x, y); int ca, cb, cc, cd; if(x == 0){ ca = v[0].first; cb = v[0].first; cc = v[0].second; cd = v[0].second; } else { ca = a[x-1]; cb = b[x-1]; cc = c[x-1]; cd = d[x-1]; } for(int i = x; i <= y; i++){ ca = min(ca, v[i].first); cb = max(cb, v[i].first); cc = min(cc, v[i].second); cd = max(cd, v[i].second); if(i+1 == (cb-ca+1)*(cd-cc+1)){ if(!lehet[i]){ lehet[i] = true; ans++; } } else { if(lehet[i]){ lehet[i] = false; ans--; } } a[i] = ca, b[i] = cb, c[i] = cc, d[i] = cd; } return ans; }
#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...