제출 #476927

#제출 시각아이디문제언어결과실행 시간메모리
476927AdamGSTeoretičar (COCI18_teoreticar)C++14
0 / 130
836 ms71008 KiB
#include<bits/stdc++.h> using namespace std; typedef long double ld; #define int long long #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() const int LIM=5e5+7; int ans[LIM]; bool ok(vector<pair<pair<int,int>,int>>V) { vector<int>l, r; for(auto i : V) { l.pb(i.st.st); r.pb(i.st.nd); } sort(all(l)); sort(all(r)); rep(i, l.size()-1) if(l[i]==l[i+1]) return false; rep(i, r.size()-1) if(r[i]==r[i+1]) return false; return true; } void dc(vector<pair<pair<int,int>,int>>V, int x) { if(V.size()==0 || ok(V)) return; vector<pair<pair<int,int>,int>>V1, V2; rep(i, V.size()) { if(i%2==0) V1.pb(V[i]); else V2.pb(V[i]); } for(auto i : V2) ans[i.nd]+=x; dc(V1, 2*x); dc(V2, 2*x); } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); int l, r, m; cin >> l >> r >> m; vector<pair<pair<int,int>,int>>V; rep(i, m) { int a, b; cin >> a >> b; V.pb({{a, b}, i}); } sort(all(V)); dc(V, 1); int ma=0; rep(i, m) ma=max(ma, ans[i]); cout << ma+1 << '\n'; rep(i, m) cout << ans[i]+1 << '\n'; }

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

teoreticar.cpp: In function 'bool ok(std::vector<std::pair<std::pair<long long int, long long int>, long long int> >)':
teoreticar.cpp:5:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
teoreticar.cpp:20:2: note: in expansion of macro 'rep'
   20 |  rep(i, l.size()-1) if(l[i]==l[i+1]) return false;
      |  ^~~
teoreticar.cpp:5:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
teoreticar.cpp:21:2: note: in expansion of macro 'rep'
   21 |  rep(i, r.size()-1) if(r[i]==r[i+1]) return false;
      |  ^~~
teoreticar.cpp: In function 'void dc(std::vector<std::pair<std::pair<long long int, long long int>, long long int> >, long long int)':
teoreticar.cpp:5:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<std::pair<long long int, long long int>, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
teoreticar.cpp:27:2: note: in expansion of macro 'rep'
   27 |  rep(i, V.size()) {
      |  ^~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...