Submission #585940

#TimeUsernameProblemLanguageResultExecution timeMemory
585940Koosha_mv자리 배치 (IOI18_seats)C++14
11 / 100
4062 ms68408 KiB
#include "seats.h" #include <bits/stdc++.h> using namespace std; #define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl #define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl #define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl #define eror(x) cout<<#x<<'='<<(x)<<endl #define f_(i,a,b) for(int i=a;i>=b;i--) #define f(i,a,b) for(int i=a;i<b;i++) #define nb(x) __builtin_popcount(x) #define all(v) v.begin(),v.end() #define bit(n,k) (((n)>>(k))&1) #define maxm(a,b) a=max(a,b) #define minm(a,b) a=min(a,b) #define lst(x) x[x.size()-1] #define sz(x) int(x.size()) #define mp make_pair #define ll long long #define pb push_back #define S second #define F first const int N=1e6+99,dx[4]={1,0,-1,0},dy[4]={0,1,0,-1}; int n,m,A[N],B[N]; vector<int> p[N]; int get(){ int ans=0,mnx=N,mxx=0,mny=N,mxy=0; f(i,0,n*m){ minm(mnx,A[i]); maxm(mxx,A[i]); minm(mny,B[i]); maxm(mxy,B[i]); if((mxx-mnx+1)*(mxy-mny+1)==i+1){ ans++; } } return ans; } void give_initial_chart(int _n, int _m, std::vector<int> _A, std::vector<int> _B) { n=_n,m=_m; f(i,0,n) f(j,0,m) p[i].pb(0); f(i,0,n*m){ A[i]=_A[i],B[i]=_B[i]; p[A[i]][B[i]]=i; } //erorp(seg[1]); } int swap_seats(int a, int b){ swap(p[A[a]][B[a]],p[A[b]][B[b]]); swap(A[a],A[b]); swap(B[a],B[b]); return get(); } /* 1 6 2 0 0 0 1 0 2 0 3 0 4 0 5 0 5 0 5 1 6 0 0 0 0 3 0 5 0 4 0 1 0 2 1 6 2 0 2 0 3 0 5 0 4 0 1 0 0 0 5 0 5 */
#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...