제출 #741048

#제출 시각아이디문제언어결과실행 시간메모리
741048almothana05자리 배치 (IOI18_seats)C++14
17 / 100
4059 ms60332 KiB
#include "seats.h" #include<bits/stdc++.h> using namespace std; int maxr[2000000] ,maxc[2000000] , minr[2000000] , minc[2000000] , vis[2000000]; int erg = 0; pair<int , int>pl[2000000]; void up(int i , int r , int c){ if(i != 0){ maxr[i] = maxr[i - 1]; maxc[i] = maxc[i - 1]; minr[i] = minr[i - 1]; minc[i] = minc[i - 1]; } else{ maxr[i] = r; maxc[i] = c; minr[i] = r; minc[i] = c; } maxr[i] = max(maxr[i] , r); maxc[i] = max(maxc[i] , c); minr[i] = min(minr[i] , r); minc[i] = min(minc[i] , c); } void give_initial_chart(int H, int W, vector<int> r, vector<int> c) { int menge = H * W; for(int i = 0 ; i < menge ; i++){ pl[i] = {r[i] , c[i]}; up(i , pl[i].first , pl[i].second); if(i + 1 == (maxr[i] - minr[i] + 1) * (maxc[i] - minc[i] + 1)){ vis[i] = 1; erg++; } } // cout << erg << "\n"; } int swap_seats(int a, int b) { if(a > b){ swap(a , b); } swap(pl[a] , pl[b]); for(int i = a ; i < b ; i++){ up(i , pl[i].first , pl[i].second); // cout << maxr[i] << ' ' << minr[i] <<' ' << maxc[i] << ' ' << minc[i] << "\n"; if(i + 1 == (maxr[i] - minr[i] + 1) * (maxc[i] - minc[i] + 1)){ if(vis[i] == 0){ vis[i] = 1; erg++; } } else{ if(vis[i] == 1){ vis[i] = 0; erg--; } } } return erg; }
#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...