Submission #213125

#TimeUsernameProblemLanguageResultExecution timeMemory
213125combi1k1Hamburg Steak (JOI20_hamburg)C++14
6 / 100
3098 ms5232 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define ld double #define sz(x) (int)x.size() #define all(x) x.begin(),x.end() #define pb emplace_back #define X first #define Y second const int N = 2e5 + 5; typedef pair<int,int> ii; struct Rec { int l, r; int u, d; } a[N]; Rec p[4]; Rec inf; Rec operator & (const Rec&a,const Rec&b) { Rec c; c.l = max(a.l,b.l); c.u = max(a.u,b.u); c.r = min(a.r,b.r); c.d = min(a.d,b.d); return c; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); srand(time(NULL)); int n; cin >> n; int k; cin >> k; inf.l = inf.u = 1; inf.r = inf.d = 1e9 ; vector<int> vec; for(int i = 0 ; i < n ; ++i) { cin >> a[i].l >> a[i].u; cin >> a[i].r >> a[i].d; vec.push_back(i); } while (1) { vector<int> nxt = vec; vec.clear(); random_shuffle(all(nxt)); fill(p,p + k,inf); for(int i : nxt) { bool ok = 0; for(int j = 0 ; j < k ; ++j) { Rec T = p[j] & a[i]; if (T.l > T.r) continue; if (T.u > T.d) continue; p[j] = T; ok = 1; break; } if(!ok) { vec = nxt; break; } } if (vec.empty()) { for(int i = 0 ; i < k ; ++i) cout << p[i].l << " " << p[i].u << "\n"; return 0; } } }
#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...