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;
vector<int> R, C;
int h, w;
void give_initial_chart(int H, int W, std::vector<int> R2, std::vector<int> C2) {
R=R2;
C=C2;
h=H;
w=W;
}
int swap_seats(int a, int b) {
swap(R[a], R[b]);
swap(C[a], C[b]);
int x1=R[0], x2=R[0], y1=C[0], y2=C[0];
int M=0, ans=0;
for(int i=1; i<h*w; i++){
x1=min(x1, R[i]);
x2=max(x2, R[i]);
y1=min(y1, C[i]);
y2=max(y2, C[i]);
if(i==(x2-x1+1)*(y2-y1+1)-1)ans++;
}
return ans+1;
}
Compilation message (stderr)
seats.cpp: In function 'int swap_seats(int, int)':
seats.cpp:17:6: warning: unused variable 'M' [-Wunused-variable]
17 | int M=0, ans=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... |