제출 #765952

#제출 시각아이디문제언어결과실행 시간메모리
765952tengiz05자리 배치 (IOI18_seats)C++17
17 / 100
4059 ms55396 KiB
#include "seats.h" #include "iostream" #ifndef EVAL #include "grader.cpp" #endif using namespace std; vector<int> r, c; vector<int> minx, maxx, miny, maxy; int n, m; int ans = 0; void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) { n = H; m = W; r = R; c = C; minx.resize(n * m, n); maxx.resize(n * m, -1); miny.resize(n * m, m); maxy.resize(n * m, -1); for (int i = 0; i < n * m; i++) { if (i == 0) { minx[i] = maxx[i] = r[i]; miny[i] = maxy[i] = c[i]; } else { minx[i] = min(minx[i - 1], r[i]); maxx[i] = max(maxx[i - 1], r[i]); miny[i] = min(miny[i - 1], c[i]); maxy[i] = max(maxy[i - 1], c[i]); } if ((maxx[i] - minx[i] + 1) * (maxy[i] - miny[i] + 1) == i + 1) { ans++; } } } int swap_seats(int a, int b) { if (a > b) swap(a, b); swap(r[a], r[b]); swap(c[a], c[b]); for (int i = a; i < b; i++) { if ((maxx[i] - minx[i] + 1) * (maxy[i] - miny[i] + 1) == i + 1) { ans--; } if (i == 0) { minx[i] = maxx[i] = r[i]; miny[i] = maxy[i] = c[i]; } else { minx[i] = min(minx[i - 1], r[i]); maxx[i] = max(maxx[i - 1], r[i]); miny[i] = min(miny[i - 1], c[i]); maxy[i] = max(maxy[i - 1], c[i]); } if ((maxx[i] - minx[i] + 1) * (maxy[i] - miny[i] + 1) == i + 1) { ans++; } } return ans; } /* 2 3 2 0 0 1 0 1 1 0 1 0 2 1 2 0 5 0 5 */
#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...