Submission #333600

#TimeUsernameProblemLanguageResultExecution timeMemory
333600nicholaskSeats (IOI18_seats)C++14
11 / 100
4097 ms48680 KiB
#include "seats.h" #include <bits/stdc++.h> using namespace std; int n,m; pair <int,int> pos[1000000]; vector <vector <int> > a; void give_initial_chart(int h,int w,vector <int> r,vector <int> c){ n=h; m=w; vector <vector <int> > v(h); for (int i=0; i<h; i++){ vector <int> e(w); v[i]=e; } for (int i=0; i<h*w; i++){ pos[i]={r[i],c[i]}; v[r[i]][c[i]]=i; } a=v; } int swap_seats(int u,int v){ pair <int,int> wha=pos[u],whb=pos[v]; swap(pos[u],pos[v]); swap(a[wha.first][wha.second],a[whb.first][whb.second]); int ans=0; int minr=1e9,maxr=-1e9,minc=1e9,maxc=-1e9; for (int i=0; i<m*n; i++){ //get pos[i] minr=min(minr,pos[i].first); maxr=max(maxr,pos[i].first); minc=min(minc,pos[i].second); maxc=max(maxc,pos[i].second); int a=(maxr-minr+1)*(maxc-minc+1); if (a==i+1) ans++; } return ans; }
#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...