제출 #1054876

#제출 시각아이디문제언어결과실행 시간메모리
1054876MinaRagy06자리 배치 (IOI18_seats)C++17
17 / 100
4033 ms60468 KiB
#include <bits/stdc++.h> #include "seats.h" #ifdef MINA #include "grader.cpp" #endif using namespace std; #define ll long long #define SZ(x) (int) x.size() const int N = 1'000'005; int mnr[N], mxr[N], mnc[N], mxc[N], gud[N], cnt = 0; int n, m; vector<int> r, c; void give_initial_chart(int _n, int _m, vector<int> _r, vector<int> _c) { n = _n, m = _m; r = _r, c = _c; mnr[0] = 1e9; mxr[0] = -1; mnc[0] = 1e9; mxc[0] = -1; for (int i = 0; i < n * m; i++) { mnr[i + 1] = min(mnr[i], r[i]); mxr[i + 1] = max(mxr[i], r[i]); mnc[i + 1] = min(mnc[i], c[i]); mxc[i + 1] = max(mxc[i], c[i]); gud[i] = (mxr[i + 1] - mnr[i + 1] + 1) * (mxc[i + 1] - mnc[i + 1] + 1) == i + 1; cnt += gud[i]; } } int swap_seats(int x, int y) { if (x > y) swap(x, y); for (int i = x; i <= y; i++) { cnt -= gud[i]; gud[i] = 0; } swap(r[x], r[y]); swap(c[x], c[y]); for (int i = x; i <= y; i++) { mnr[i + 1] = min(mnr[i], r[i]); mxr[i + 1] = max(mxr[i], r[i]); mnc[i + 1] = min(mnc[i], c[i]); mxc[i + 1] = max(mxc[i], c[i]); gud[i] = (mxr[i + 1] - mnr[i + 1] + 1) * (mxc[i + 1] - mnc[i + 1] + 1) == i + 1; cnt += gud[i]; } return cnt; }
#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...