Submission #1014968

#TimeUsernameProblemLanguageResultExecution timeMemory
1014968hyakupSeats (IOI18_seats)C++17
0 / 100
3638 ms59476 KiB
#include "seats.h" #include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; vector<int> l1(maxn, maxn), l2(maxn, -maxn), c1(maxn, maxn), c2(maxn, -maxn), marc(maxn); vector<int> i, j; int resp; void give_initial_chart(int H, int W, vector<int> R, vector<int> C) { i = R; j = C; for( int k = 1; k <= H*W; k++ ){ l1[k] = min(l1[k - 1], i[k - 1] ); l2[k] = max(l2[k - 1], i[k - 1] ); c1[k] = min(c1[k - 1], j[k - 1] ); c2[k] = max(c2[k - 1], j[k - 1] ); if( (l2[k] - l1[k] + 1)*(c2[k] - c1[k] + 1) == k ){ marc[k] = 1; resp++; } } } int swap_seats(int a, int b) { swap( i[a], i[b] ); swap( j[a], j[b] ); for( int k = a + 1; k <= b + 1; k++ ){ if( marc[k] ){ marc[k] = 0; resp--; } l1[k] = min(l1[k - 1], i[k - 1] ); l2[k] = max(l2[k - 1], i[k - 1] ); c1[k] = min(c1[k - 1], j[k - 1] ); c2[k] = max(c2[k - 1], j[k - 1] ); if( (l2[k] - l1[k] + 1)*(c2[k] - c1[k] + 1) == k ){ marc[k] = 1; resp++; } } return resp; }
#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...