This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
Compilation message (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... |