Submission #1248655

#TimeUsernameProblemLanguageResultExecution timeMemory
1248655countlessSeats (IOI18_seats)C++20
11 / 100
4094 ms32052 KiB
#include "seats.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define sp <<" "<< #define endl "\n" ll h, w; vector<ll> r, c; void give_initial_chart(int H, int W, vector<int> R, vector<int> C) { h = H, w = W; r = vector<ll>(R.begin(), R.end()); c = vector<ll>(C.begin(), C.end()); } bool check(int r1, int c1, int r2, int c2, ll x) { ll he = r2 - r1 + 1, we = c2 - c1 + 1; ll amt = he * we; return amt == x+1; } // to opt: process in linear order (must always eq 0, etc) int swap_seats(int a, int b) { // perform swap { if (a > b) swap(a, b); ll diff = b - a; swap(r[a], r[b]); swap(c[a], c[b]); } // count int res = 0; ll r1, c1, r2, c2; r1 = r2 = r[0]; c1 = c2 = c[0]; res += check(r1, c1, r2, c2, 0); for (ll i = 1; i < h * w; i++) { r1 = min(r1, r[i]); r2 = max(r2, r[i]); c1 = min(c1, c[i]); c2 = max(c2, c[i]); res += check(r1, c1, r2, c2, i); } 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...