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;
void give_initial_chart(int H, int W, vector<int> R, vector<int> C) {
r=R,c=C;
}
int swap_seats(int a, int b) {
swap(r[a],r[b]);
swap(c[a],c[b]);
int min_r = r[0], max_r = r[0], min_c = c[0], max_c = c[0];
int cnt = 1;
for(int i=1;i<r.size();i++) {
min_r = min(min_r, r[i]);
max_r = max(max_r, r[i]);
min_c = min(min_c, c[i]);
max_c = max(max_c, c[i]);
// cerr << (max_r - min_r) * (max_c - min_c) << ' ' << i+1 << endl;
if((max_r - min_r + 1) * (max_c - min_c + 1) == i + 1) cnt++;
}
return cnt;
}
Compilation message (stderr)
seats.cpp: In function 'int swap_seats(int, int)':
seats.cpp:18:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | for(int i=1;i<r.size();i++) {
| ~^~~~~~~~~
# | 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... |