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>
#define endl '\n'
using namespace std;
std::vector<int> r;
const int N = 1e3 + 4;
const int M = 1e4 + 4;
int arr[N][N];
pair<int,int> where[M];
int h, w;
void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) {
int siz = R.size();
h = H, w = W;
for(int i = 0; i < siz; i++) {
arr[R[i]][C[i]] = i;
where[i].first = R[i];
where[i].second = C[i];
}
}
int swap_seats(int a, int b) {
int x1 = where[a].first, y1 = where[a].second;
int x2 = where[b].first, y2 = where[b].second;
swap(arr[x1][y1],arr[x2][y2]);
swap(where[a],where[b]);
long long arr2[h+1][w+1] = {};
cout << h << ' ' << w << endl;
for(int i = 1; i <= h; i++) {
for(int j = 1; j <= w; j++) {
arr2[i][j] = arr[i-1][j-1];
}
}
for(int i = 0; i <= h; i++) {
for(int j = 0; j <= w; j++) {
cout << arr2[i][j] <<' ';
}
cout << endl;
}
for(int i = 0; i <= h; i++) {
for(int j = 1; j <= w; j++) {
arr2[i][j] += arr2[i][j-1];
}
}
for(int j = 0; j <= w; j++) {
for(int i = 1; i <= h; i++) {
arr2[i][j] += arr2[i-1][j];
}
}
int ans = 0;
for(int i1 = 1; i1 <= h; i1++) {
for(int j1 = 1; j1 <= w; j1++) {
for(int i2 = 1; i2 <= h; i2++) {
for(int j2 = 1; j2 <= w; j2++) {
if(i2 < i1 || j2 < j1) continue;
long long sum = arr2[i2][j2] - arr2[i1-1][j2] - arr2[i2][j1-1] + arr2[i1-1][j1-1];
long long num = (i2-i1+1) * (j2-j1+1);
long long sum2 = num * (num-1ll) /2ll;
if(sum == sum2) ans++;
}
}
}
}
return ans;
}
/*2 3 2
0 0
1 0
1 1
0 1
0 2
1 2
0 5
0 5*/
# | 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... |