# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
82526 | farukkastamonuda | Seats (IOI18_seats) | C++14 | 0 ms | 0 KiB |
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 fi first
#define se second
#define lo long long
#define inf 1000000009
#define md 1000000007
#define li 200005
#define mp make_pair
#define pb push_back
#define mid (start+end)/2
using namespace std;
int A[105][105],n,m;
pair<int,int> konum[10005];
void give_initial_chart(int H,int W,int R[],int C[]){
n=H;
m=W;
for(int i=0;i<H*W;i++){
int sat=i/W;
int sut=i%W;
A[sat][sut]=i;
konum[i]=mp(sat,sut);
}
}
int swap_seats(int a,int b){
int cev=0;
int sat1=konum[a].fi,sut1=konum[a].se;
int sat2=konum[b].fi,sut2=konum[b].se;
int temp=A[sat1][sut1];
konum[temp]=mp(sat2,sut2);
konum[b]=mp(sat1,sut1);
A[sat1][sut1]=A[sat2][sut2];
A[sat2][sut2]=temp;
int sifs=konum[0].fi,sifsu=konum[0].se;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
int mx=abs(i-sifs)*abs(j-sifsu)-1;
int flag=0;
for(int k=min(i,sifs);k<max(sifs,i);k++){
for(int t=min(j,sifsu);t<max(j,sifsu);t++){
if(A[k][t]>mx){
flag=1;
break;
}
}
if(flag==1) break;
}
if(flag==0) cev++;
}
}
return cev;
}
//~ int main(){
//~ return 0;
//~ }