(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #1105289

#TimeUsernameProblemLanguageResultExecution timeMemory
1105289thelegendary08Seats (IOI18_seats)C++14
0 / 100
3076 ms58932 KiB
#include "seats.h" #include<bits/stdc++.h> #define f0r(i,n) for(int i=0; i<n; i++) #define pb push_back #define vi vector<int> #define pii pair<int,int> using namespace std; vector<pair<int,int>>v; vector<pair<pii,pii>>state; vector<bool>nice; int ca; int h, w; void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) { h = H; w = W; ca = 0; f0r(i, H * W){ v.pb({R[i], C[i]}); } pii x = {v[0].first, v[0].first}; pii y = {v[0].second, v[0].second}; nice.resize(h*w); f0r(i, h*w){ x.first = min(v[i].first, x.first); x.second = max(v[i].first, x.second); y.first = min(v[i].second, y.first); y.second = max(v[i].second, y.second); state.pb({x,y}); if((x.second - x.first + 1) * (y.second - y.first + 1) == i+1){ nice[i] = 1; ca++; } else{ nice[i] = 0; } } //cout<<ca<<'\n'; } int swap_seats(int a, int b) { swap(v[a], v[b]); pii x; pii y; if(a == 0)x = {1e9, -1}; else x = state[a-1].first; if(a == 0)y = {1e9, -1}; else y = state[a-1].second; int minus = 0; for(int i = a; i<=b; i++){ minus += nice[i]; } ca -= minus; int plus = 0; for(int i = a; i<=b; i++){ x.first = min(v[i].first, x.first); x.second = max(v[i].first, x.second); y.first = min(v[i].second, y.first); y.second = max(v[i].second, y.second); state[i] = {x,y}; if((x.second - x.first + 1) * (y.second - y.first + 1) == i+1){ nice[i] = 1; plus++; } else{ nice[i] = 0; } } ca += plus; //cout<<minus<<' '<<plus<<'\n'; return ca; }
#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...