제출 #247518

#제출 시각아이디문제언어결과실행 시간메모리
247518srvlt자리 배치 (IOI18_seats)C++14
0 / 100
397 ms64376 KiB
#include "seats.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define ll long long #define ld long double #define pb push_back #define all(x) (x).begin(), (x).end() #define SZ(x) (int)(x).size() template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int n = 105; vector <int> r, c; int rc[n][n], cc[n][n], rz[n], cz[n], res, h, w; void add(int i, int j) { if (!rc[i][r[j]]) rz[i]--; rc[i][r[j]]++; rc[i][r[j] + 1]--; if (!rc[i][r[j] + 1]) rz[i]++; if (!cc[i][c[j]]) cz[i]--; cc[i][c[j]]++; cc[i][c[j] + 1]--; if (!cc[i][c[j] + 1]) cz[i]++; } void del(int i, int j) { rc[i][r[j]]--; if (!rc[i][r[j]]) rz[i]++; if (!rc[i][r[j] + 1]) rz[i]--; rc[i][r[j] + 1]++; cc[i][c[j]]--; if (!cc[i][c[j]]) cz[i]++; if (!cc[i][c[j] + 1]) cz[i]--; cc[i][c[j] + 1]++; } void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) { r = R, c = C, h = H, w = W; for (int i = 0; i < H * W; i++) { rz[i] = H + 1, cz[i] = W + 1; for (int j = 0; j <= i; j++) { add(i, j); } if (rz[i] == H - 1 && cz[i] == W - 1) res++; } } int swap_seats(int a, int b) { if (a > b) swap(a, b); for (int i = a + 1; i < b; i++) { if (rz[i] == h - 1 && cz[i] == w - 1) res--; del(i, a); add(i, b); if (rz[i] == h - 1 && cz[i] == w - 1) res++; } swap(r[a], r[b]); swap(c[a], c[b]); return res; }
#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...