Submission #138202

#TimeUsernameProblemLanguageResultExecution timeMemory
138202Lawliet자리 배치 (IOI18_seats)C++14
11 / 100
1484 ms33752 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...