제출 #428975

#제출 시각아이디문제언어결과실행 시간메모리
428975wiwiho마상시합 토너먼트 (IOI12_tournament)C++14
100 / 100
189 ms11900 KiB
#include <bits/stdc++.h> #include <bits/extc++.h> #define mp make_pair #define F first #define S second #define eb emplace_back #define iter(a) a.begin(), a.end() #define lsort(a) sort(iter(a)) #define uni(a) a.resize(unique(iter(a))); #define printv(a, b) { \ for(auto pv : a) b << pv << " "; \ b << "\n"; \ } using namespace std; typedef long long ll; using pii = pair<int, int>; using tree = __gnu_pbds::tree<int, __gnu_pbds::null_type, less<>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>; const ll MOD = 1000000000; int GetBestPosition(int n, int m, int R, int *K, int *S, int *E) { vector<int> pos; for(int i = 0; i < n - 1; i++){ if(K[i] > R) pos.eb(i); } tree tr; for(int i = 0; i <= n; i++) tr.insert(i); vector<pii> ev; vector<bool> kill(m); for(int i = 0; i < m; i++){ auto lit = tr.find_by_order(S[i]); auto rit = tr.find_by_order(E[i]); S[i] = *lit; E[i] = *next(rit) - 1; for(auto it = next(lit); *it <= E[i]; it = tr.erase(it)); ev.eb(mp(S[i], i + 1)); ev.eb(mp(E[i] + 1, -i - 1)); auto it = lower_bound(iter(pos), S[i]); kill[i] = it != pos.end() && *it < E[i]; } lsort(ev); tree now; set<int> ks; int ep = 0; int ans = 0, ansp = 0; for(int i = 0; i < n; i++){ while(ep < ev.size() && ev[ep].F <= i){ if(ev[ep].S > 0){ int id = ev[ep].S - 1; now.insert(id); if(kill[id]) ks.insert(id); } else{ int id = -ev[ep].S - 1; now.erase(id); ks.erase(id); } ep++; } int tans; if(ks.empty()) tans = now.size(); else tans = now.order_of_key(*ks.begin()); if(tans > ans){ ans = tans; ansp = i; } } return ansp; }

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

tournament.cpp: In function 'int GetBestPosition(int, int, int, int*, int*, int*)':
tournament.cpp:55:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         while(ep < ev.size() && ev[ep].F <= i){
      |               ~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...