제출 #835149

#제출 시각아이디문제언어결과실행 시간메모리
835149Johann자리 배치 (IOI18_seats)C++14
11 / 100
4083 ms24120 KiB
#include "seats.h"
#include "bits/stdc++.h"
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

int H, W;
std::vector<int> R, C;

void give_initial_chart(int _H, int _W, std::vector<int> _R, std::vector<int> _C)
{
    H = _H, W = _W;
    R = _R, C = _C;
}

int swap_seats(int a, int b)
{
    swap(R[a], R[b]), swap(C[a], C[b]);

    int rmax = R[0], rmin = R[0];
    int cmax = C[0], cmin = C[0];
    int ans = 0;
    for (int k = 0; k < H * W; ++k)
    {
        rmax = max(rmax, R[k]);
        rmin = min(rmin, R[k]);
        cmax = max(cmax, C[k]);
        cmin = min(cmin, C[k]);
        int area = (rmax - rmin + 1) * (cmax - cmin + 1);
        if (area == k + 1)
            ++ans;
        assert(area >= k + 1);
    }

    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...