이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define MAX 10010
#define INF 1000000
using namespace std;
typedef pair<int,int> pii;
typedef long long int lli;
int N, M;
pii pos[MAX];
vector<int> v[MAX];
void give_initial_chart(int H, int W, vector<int> R, vector<int> C)
{
N = H; M = W;
for(int g = 0 ; g < N*M ; g++)
pos[g] = {R[g] , C[g]};
}
int swap_seats(int a, int b)
{
swap(pos[a] , pos[b]);
//printf(" -> %d %d\n",pos[0].first,pos[0].second);
int ans = 0;
int mxX = -INF;
int mnX = INF;
int mxY = -INF;
int mnY = INF;
for(int g = 0 ; g < N*M ; g++)
{
mxX = max(mxX , pos[g].first);
mnX = min(mnX , pos[g].first);
mxY = max(mxY , pos[g].second);
mnY = min(mnY , pos[g].second);
//printf("-> %d %d %d %d\n",mxX,mnX,mxY,mnY);
if((mxX - mnX +1 )*(mxY - mnY+1) == g + 1)
ans++;
}
return ans;
}
/*int main()
{
int nn, mm, qq;
scanf("%d %d %d",&nn,&mm,&qq);
vector<int> rr(nn*mm), cc(nn*mm);
for(int g = 0 ; g < nn*mm ; g++)
scanf("%d %d",&rr[g],&cc[g]);
give_initial_chart(nn , mm , rr , cc);
for(int g = 0 ; g < qq ; g++)
{
int n1, n2;
scanf("%d %d",&n1,&n2);
printf("%d",swap_seats(n1 , n2));
}
}*/
| # | 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... |