이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "seats.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int h,w;
ii pos[1000005];
void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) {
h=H,w=W;
for (int x=0;x<h*w;x++){
pos[x]=ii(R[x],C[x]);
}
//print();
}
int swap_seats(int a, int b) {
swap(pos[a],pos[b]);
//print();
int x1,x2,y1,y2;
x1=x2=pos[0].first;
y1=y2=pos[0].second;
int s=1;
int biggest=0;
int res=1;
for (int x=1;x<h*w;x++){
while (pos[x].first<x1){
x1--;
s+=y2-y1+1;
}
while (x2<pos[x].first){
x2++;
s+=y2-y1+1;
}
while (pos[x].second<y1){
y1--;
s+=x2-x1+1;
}
while (y2<pos[x].second){
y2++;
s+=x2-x1+1;
}
if (s==x+1) res++;
}
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
seats.cpp: In function 'int swap_seats(int, int)':
seats.cpp:28:6: warning: unused variable 'biggest' [-Wunused-variable]
int biggest=0;
^~~~~~~| # | 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... |