제출 #1052483

#제출 시각아이디문제언어결과실행 시간메모리
1052483Ahmed57자리 배치 (IOI18_seats)C++17
25 / 100
4065 ms119084 KiB
#include "bits/stdc++.h" using namespace std; set<int> rw[10001],cl[10001]; vector<int> r,c; int h,w; void give_initial_chart(int H, int W, vector<int> R, vector<int> C){ h = H; w = W; for(int i = 0;i<H*W;i++){ r.push_back(R[i]); c.push_back(C[i]); rw[R[i]].insert(i); cl[C[i]].insert(i); } } int swap_seats(int a, int b){ rw[r[a]].erase(a); cl[c[a]].erase(a); rw[r[b]].erase(b); cl[c[b]].erase(b); rw[r[b]].insert(a); cl[c[b]].insert(a); rw[r[a]].insert(b); cl[c[a]].insert(b); swap(r[a],r[b]); swap(c[a],c[b]); vector<array<int,3>> ev; for(int i = 0;i<h;i++){ ev.push_back({*rw[i].begin(),i,0}); } for(int i = 0;i<w;i++){ ev.push_back({*cl[i].begin(),i,1}); } sort(ev.begin(),ev.end()); int mnx = 1e9 , mxx = -1e9; int mny = 1e9 , mxy = -1e9; int ans = 1; int it = 0; while(it<ev.size()){ int it2 = it; while(it2<ev.size()&&ev[it2][0]==ev[it][0]){ if(ev[it2][2]==0){ mnx = min(mnx,ev[it2][1]); mxx = max(mxx,ev[it2][1]); }else{ mny = min(mny,ev[it2][1]); mxy = max(mxy,ev[it2][1]); } it2++; } if(it2==ev.size())break; if((mxx-mnx+1)*(mxy-mny+1)==ev[it2][0]){ ans++; } it = it2; } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

seats.cpp: In function 'int swap_seats(int, int)':
seats.cpp:40:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     while(it<ev.size()){
      |           ~~^~~~~~~~~~
seats.cpp:42:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         while(it2<ev.size()&&ev[it2][0]==ev[it][0]){
      |               ~~~^~~~~~~~~~
seats.cpp:52:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         if(it2==ev.size())break;
      |            ~~~^~~~~~~~~~~
#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...