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;
const int N = 10005;
std::vector<int> r;
int posX[N] ,posY[N];
int H , W;
void give_initial_chart(int Hw, int Ww, std::vector<int> R, std::vector<int> C) {
H = Hw, W = Ww;
for(int i = 0 ; i < R.size() ; i ++){
posX[i] = R[i];
posY[i] = C[i];
}
}
int swap_seats(int a, int b) {
swap(posX[a] , posX[b]);
swap(posY[a] , posY[b]);
int minvlX = 1000000000 , maxvlX = -1;
int minvlY = 1000000000 , maxvlY = -1;
int cnt = 0;
for(int i = 0 ; i < H*W ; i++){
minvlX = min(minvlX , posX[i]) , maxvlX = max(maxvlX , posX[i]);
minvlY = min(minvlY , posY[i]) , maxvlY = max(maxvlY , posY[i]);
if((abs(minvlX - maxvlX ) + 1 ) * (abs(minvlY - maxvlY) + 1) == i + 1){
cnt++;
}
}
return cnt;
}
Compilation message (stderr)
seats.cpp: In function 'void give_initial_chart(int, int, std::vector<int>, std::vector<int>)':
seats.cpp:10:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0 ; 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... |