Submission #623695

#TimeUsernameProblemLanguageResultExecution timeMemory
623695MateGiorbelidzeSeats (IOI18_seats)C++14
0 / 100
4083 ms39364 KiB
#include "seats.h" #include <bits/stdc++.h> using namespace std; #define ll long long std::vector<int> r , c , mxr, mxc, mnr, mnc; int ans = 0 , h , w; void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) { r = R; c = C; h = H; w = W; mxr.resize( h * w + 1 ); mxc.resize( h * w + 1 ); mnr.resize( h * w + 1 ); mnc.resize( h * w + 1 ); mxr[0] = mxc[0] = INT_MIN; mnr[0] = mnc[0] = INT_MAX; for (int i = 1; i <= h * w; i++) { mxr[i] = max(mxr[i - 1] , r[i - 1]); mxc[i] = max(mxc[i - 1] , c[i - 1]); mnr[i] = min(mnr[i - 1] , r[i - 1]); mnc[i] = min(mnc[i - 1] , c[i - 1]); int val = (mxr[i] - mnr[i] + 1) * (mxc[i] - mnc[i] + 1); //cout<<i<<" "<<val<<'\n'; if (val == i) ans++; else i = val - 1; } } int swap_seats(int a, int b) { a++; b++; if (a > b) swap(a , b); for (int i = a; i <= b; i++) { int val = (mxr[i] - mnr[i] + 1) * (mxc[i] - mnc[i] + 1); if (val == i) ans--; else i = val - 1; } swap (r[a - 1] , r[b - 1]); swap (c[a - 1] , c[b - 1]); for (int i = a; i <= b; i++) { mxr[i] = max(mxr[i - 1] , r[i - 1]); mxc[i] = max(mxc[i - 1] , c[i - 1]); mnr[i] = min(mnr[i - 1] , r[i - 1]); mnc[i] = min(mnc[i - 1] , c[i - 1]); int val = (mxr[i] - mnr[i] + 1) * (mxc[i] - mnc[i] + 1); if (val == i) ans++; else i = val - 1; } 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...