#include "seats.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> r, c;
int mr, mc, mmc, mmr, h, w;
map<pair<int,int>,bool> st;
bool check(int l){
for(int i = mr; i <= mmr; i++) for(int j = mc; j <= mmc; j++) if(!st[{i,j}]) return false;
return true;
}
void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) {
r = R; c = C; h = H; w = W;
}
int swap_seats(int a, int b) {
mr = 1e9; mc = 1e9; mmc = 0; mmr = 0;
st.clear();
swap(r[a],r[b]);
swap(c[a],c[b] );
int cnt = 0;
for(int i = 0; i <= h * w - 1; i++) {
mr = min(mr, r[i]);
mmr = max(mmr, r[i]);
mc = min(mc, c[i]);
mmc = max(mmc, c[i]);
st[{r[i],c[i]}] = 1;
if(check(i)) cnt++;
}
return cnt;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
604 KB |
Output is correct |
2 |
Correct |
24 ms |
596 KB |
Output is correct |
3 |
Correct |
79 ms |
568 KB |
Output is correct |
4 |
Correct |
76 ms |
596 KB |
Output is correct |
5 |
Correct |
285 ms |
548 KB |
Output is correct |
6 |
Correct |
75 ms |
568 KB |
Output is correct |
7 |
Correct |
77 ms |
572 KB |
Output is correct |
8 |
Correct |
110 ms |
704 KB |
Output is correct |
9 |
Correct |
311 ms |
536 KB |
Output is correct |
10 |
Correct |
78 ms |
580 KB |
Output is correct |
11 |
Correct |
79 ms |
536 KB |
Output is correct |
12 |
Correct |
155 ms |
576 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
604 KB |
Output is correct |
2 |
Correct |
24 ms |
596 KB |
Output is correct |
3 |
Correct |
79 ms |
568 KB |
Output is correct |
4 |
Correct |
76 ms |
596 KB |
Output is correct |
5 |
Correct |
285 ms |
548 KB |
Output is correct |
6 |
Correct |
75 ms |
568 KB |
Output is correct |
7 |
Correct |
77 ms |
572 KB |
Output is correct |
8 |
Correct |
110 ms |
704 KB |
Output is correct |
9 |
Correct |
311 ms |
536 KB |
Output is correct |
10 |
Correct |
78 ms |
580 KB |
Output is correct |
11 |
Correct |
79 ms |
536 KB |
Output is correct |
12 |
Correct |
155 ms |
576 KB |
Output is correct |
13 |
Execution timed out |
4016 ms |
1368 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4077 ms |
94624 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4018 ms |
1484 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
2008 KB |
Output is correct |
2 |
Correct |
61 ms |
1980 KB |
Output is correct |
3 |
Correct |
1571 ms |
2048 KB |
Output is correct |
4 |
Execution timed out |
4049 ms |
1576 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
604 KB |
Output is correct |
2 |
Correct |
24 ms |
596 KB |
Output is correct |
3 |
Correct |
79 ms |
568 KB |
Output is correct |
4 |
Correct |
76 ms |
596 KB |
Output is correct |
5 |
Correct |
285 ms |
548 KB |
Output is correct |
6 |
Correct |
75 ms |
568 KB |
Output is correct |
7 |
Correct |
77 ms |
572 KB |
Output is correct |
8 |
Correct |
110 ms |
704 KB |
Output is correct |
9 |
Correct |
311 ms |
536 KB |
Output is correct |
10 |
Correct |
78 ms |
580 KB |
Output is correct |
11 |
Correct |
79 ms |
536 KB |
Output is correct |
12 |
Correct |
155 ms |
576 KB |
Output is correct |
13 |
Execution timed out |
4016 ms |
1368 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |