Submission #229947

#TimeUsernameProblemLanguageResultExecution timeMemory
229947fedoseevtimofeySeats (IOI18_seats)C++14
11 / 100
4070 ms48760 KiB
#include "seats.h" #include <iostream> #include <string> #include <vector> #include <queue> #include <deque> #include <stack> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #include <cstring> #include <cmath> #include <cstdlib> #include <algorithm> #include <random> #include <iomanip> #include <functional> #include <cassert> using namespace std; typedef long long ll; vector <vector <int>> a; vector <int> r, c; int n, m; void give_initial_chart(int N, int M, vector<int> R, vector<int> C) { n = N, m = M; r = R, c = C; a.resize(n, vector <int> (m)); for (int i = 0; i < n * m; ++i) { a[r[i]][c[i]] = i; } } int swap_seats(int x, int y) { swap(a[r[x]][c[x]], a[r[y]][c[y]]); swap(r[x], r[y]); swap(c[x], c[y]); int min_r = n, max_r = 0, min_c = m, max_c = 0; int ans = 0; for (int i = 0; i < n * m; ++i) { min_r = min(min_r, r[i]); max_r = max(max_r, r[i]); min_c = min(min_c, c[i]); max_c = max(max_c, c[i]); if ((max_r - min_r + 1) * (max_c - min_c + 1) == i + 1) { ++ans; } } return ans; } #ifdef LOCAL int main() { ios_base::sync_with_stdio(false); cin.tie(0); #ifdef LOCAL freopen("input.txt", "r", stdin); #endif int n, m, q; cin >> n >> m >> q; vector <int> R(n * m), C(n * m); for (int i = 0; i < n * m; ++i) { cin >> R[i] >> C[i]; } vector <int> aq(q), bq(q); for (int i = 0; i < q; ++i) { cin >> aq[i] >> bq[i]; } give_initial_chart(n, m, R, C); for (int j = 0; j < q; ++j) { cout << swap_seats(aq[j], bq[j]) << '\n'; } } #endif
#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...