제출 #107515

#제출 시각아이디문제언어결과실행 시간메모리
107515kyunamk자리 배치 (IOI18_seats)C++14
0 / 100
351 ms32148 KiB
#include "seats.h" #include <utility> #include <iostream> using namespace std; std::vector<int> r; std::vector<int> c; std::vector< pair<int,int> > pos; int K; // int debug = true; //false; int debug = false; void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C) { r = R; c = C; K = R.size(); for ( int i = 0 ; i < K ; i++) { // if( debug ) cout << R[i] << C[i] << endl; pos.push_back(make_pair(R[i],C[i])); } //debug = true; } int r1,r2,c1,c2; int add_rect( int r, int c) { int changed = 0; if ( r >= r1 && r <= r2 && c >= c1 && c <= c2) changed = 0; else { if ( r < r1 ) r1 = r; else if( r > r2 ) r2 = r; if ( c < c1 ) c1 = c; else if( c > c2 ) c2 = c; changed = 1; } return changed ; } int swap_seats(int a, int b) { if( debug ) cout << "Swap : " << a << b << endl; pair<int,int> t = pos[b]; pos[b]=pos[a]; pos[a]=t; r1=r2=pos[0].first; c1=c2=pos[0].second; int cnt = 0; if( debug ) cout << 0 << r1 << r2 << c1 << c2 << endl; for( int i =0 ; i < K ; ) { int changed = add_rect( pos[i].first , pos[i].second ) ; if( debug ) { cout << i << changed << r1 << r2 << c1 << c2 << endl; } if ( (r2-r1+1)*(c2-c1+1) <= i+1 ) { if( debug ) cout << "BRect " << i+1 << endl; cnt++; i++; } else { i = (r2-r1+1)*(c2-c1+1)-1; } } return cnt; }
#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...