제출 #145230

#제출 시각아이디문제언어결과실행 시간메모리
145230kdh9949자리 배치 (IOI18_seats)C++17
0 / 100
4090 ms55416 KiB
#include "seats.h" #include <bits/stdc++.h> using namespace std; const int N = 1000005; int x[N], y[N], mx[N], Mx[N], my[N], My[N], r; void cal(int a[], int m[], int M[], int s, int e){ for(int i = s; i <= e; i++){ m[i] = min(m[i - 1], a[i]); M[i] = max(M[i - 1], a[i]); } } void ch(int s, int e, int x){ for(int i = s; i <= e; i++) if(1LL * (Mx[i] - mx[i] + 1) * (My[i] - my[i] + 1) == i) r += x; } void give_initial_chart(int H, int W, vector<int> R, vector<int> C) { for(int i = 0; i < H * W; i++){ x[i + 1] = R[i]; y[i + 1] = C[i]; } mx[0] = my[0] = N; cal(x, mx, Mx, 1, H * W); cal(y, my, My, 1, H * W); ch(1, H * W, 1); } int swap_seats(int a, int b){ a++; b++; if(a > b) swap(x, y); swap(x[a], x[b]); swap(y[a], y[b]); ch(a, b - 1, -1); cal(x, mx, Mx, a, b - 1); cal(y, my, My, a, b - 1); ch(a, b - 1, 1); return r; }
#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...