이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "seats.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>>v;
vector<pair<int,int>>loc;
int N,M;
void give_initial_chart(int n, int m, vector<int>r, vector<int>c) {
N = n, M = m;
v.resize(n);
loc.resize(n*m);
for(auto &z : v)
z.resize(m);
for(int i = 0 ; i < n*m ; i++)
v[r[i]][c[i]] = i, loc[i] = {r[i], c[i]};
}
int swap_seats(int a, int b) {
swap(v[loc[a].first][loc[a].second], v[loc[b].first][loc[b].second]);
swap(loc[a], loc[b]);
int sz = 0;
int x1 = N, x2 = -1, y1 = M, y2 = -1;
int ans = 0;
while(sz < N*M) {
//cout << sz << ' ' << x1 << ' ' << x2 << ' ' << y1 << ' ' << y2 << '\n';
x1 = min(x1, loc[sz].first), x2 = max(x2, loc[sz].first);
y1 = min(y1, loc[sz].second), y2 = max(y2, loc[sz].second);
ans += ((x2 - x1 + 1) * (y2 - y1 + 1) == sz+1 ? 1 : 0);
sz++;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |