Submission #125178

#TimeUsernameProblemLanguageResultExecution timeMemory
125178chubyxdxdSeats (IOI18_seats)C++11
0 / 100
358 ms39636 KiB
#include "seats.h" #include <bits/stdc++.h> using namespace std; #define pb push_back std::vector<int> r; std::vector<int> c; typedef pair<int,int> ii; vector<int> vmaxx; vector<int> vmaxy; vector<int> vminy; vector<int> vminx; int g=0,e,d; void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) { r = R; c = C; int maxx=r[0],minx=r[0],maxy=c[0],miny=c[0]; for(int i=0;i<H*W;i++){ int x1,y1; x1=r[i]; y1=c[i]; maxx=max(maxx,x1); minx=min(minx,x1); maxy=max(maxy,y1); miny=min(miny,y1); d=abs(maxx-minx)+1; e=abs(maxy-miny)+1; if(d*e==i+1){ g++; } vmaxx.pb(maxx); vmaxy.pb(maxy); vminx.pb(minx); vminy.pb(miny); } //cout<<g<<endl; } int swap_seats(int a, int b) { int x1,y1; //int x2,y2; swap(r[a],r[b]); swap(c[a],c[b]); if(abs(a-b)<=10000){ int j=min(a,b); int k=max(a,b); for(int i=j;i<=k;i++){ d=abs(vmaxx[i]-vminx[i])+1; e=abs(vmaxy[i]-vminy[i])+1; if(e*d==i+1){ g--; } } int maxx=r[j],minx=r[j],maxy=c[j],miny=c[j]; for(int i=j;i<=k;i++){ x1=r[i]; y1=c[i]; maxx=max(maxx,x1); minx=min(minx,x1); maxy=max(maxy,y1); miny=min(miny,y1); vmaxx[i]=maxx; vmaxy[i]=maxy; vminx[i]=minx; vminy[i]=miny; d=abs(vmaxx[i]-vminx[i])+1; e=abs(vmaxy[i]-vminy[i])+1; if(e*d==i+1){ g++; } } return g; } }

Compilation message (stderr)

seats.cpp: In function 'int swap_seats(int, int)':
seats.cpp:72:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#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...