제출 #792844

#제출 시각아이디문제언어결과실행 시간메모리
792844fatemetmhr자리 배치 (IOI18_seats)C++17
11 / 100
4043 ms24656 KiB
// Be name khode //


#include "seats.h"
#include <bits/stdc++.h>
 
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

 
#define all(x) x.begin(), x.end()
#define pb     push_back
#define fi     first
#define se     second
#define mp     make_pair
 
typedef long long ll;
 
const int maxn = 1e6 + 10;
const int lg    = 20;

std::vector<int> r;

int n, m;
pair <int, int> a[maxn];

void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) {
    n = H;
    m = W;
    for(int i = 0; i < n * m; i++)
        a[i] = {R[i], C[i]};
}

int swap_seats(int x, int y) {
    swap(a[x], a[y]);
    pair <int, int> h, w;
    h = {a[0].fi, a[0].fi};
    w = {a[0].se, a[0].se};
    int ans = 0;
    for(int i = 0; i < n * m; i++){
        h.fi = max(h.fi, a[i].fi);
        h.se = min(h.se, a[i].fi);
        w.fi = max(w.fi, a[i].se);
        w.se = min(w.se, a[i].se);

        if((h.fi - h.se + 1) * (w.fi - w.se + 1) == i + 1)
            ans++;
    }
    return ans;
}
#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...