제출 #1043528

#제출 시각아이디문제언어결과실행 시간메모리
1043528Zicrus자리 배치 (IOI18_seats)C++17
11 / 100
4085 ms41040 KiB
#include <bits/stdc++.h>
#include "seats.h"
using namespace std;

typedef long long ll;

int n, w, h;
vector<int> x, y;

void give_initial_chart(int h1, int w1, vector<int> r, vector<int> c) {
    w = w1; h = h1;
    n = h*w;
    x = c; y = r;
}

int swap_seats(int a, int b) {
    swap(x[a], x[b]);
    swap(y[a], y[b]);
    int res = 1;
    int left = x[0], right = x[0], top = y[0], bot = y[0];
    for (int i = 1; i < n; i++) {
        left = min(left, x[i]);
        right = max(right, x[i]);
        top = min(top, y[i]);
        bot = max(bot, y[i]);
        if ((right-left+1) * (bot-top+1) == i+1) res++;
    }
    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...