Submission #229396

#TimeUsernameProblemLanguageResultExecution timeMemory
229396_7_7_Hamburg Steak (JOI20_hamburg)C++14
21 / 100
3049 ms6772 KiB
#include <bits/stdc++.h> //#define int long long //#pragma GCC optimize("Ofast") //#pragma comment(linker, "/stack:200000000") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4") #define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout); #define all(x) x.begin(), x.end() #define sz(s) (int)s.size() #define pb push_back #define ppb pop_back #define mp make_pair #define s second #define f first using namespace std; typedef pair < long long, long long > pll; typedef pair < int, int > pii; typedef unsigned long long ull; typedef vector < pii > vpii; typedef vector < int > vi; typedef long double ldb; typedef long long ll; typedef double db; const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 333; const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9); const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 3e5 + 11; const db eps = 1e-12, pi = 3.14159265359; const ll INF = 1e18; int n, k, xa[N], xb[N], ya[N], yb[N]; bool inter (int l1, int r1, int l2, int r2) { if (l1 > l2) { swap(l1, l2); swap(r1, r2); } return l2 <= r1; } main () { srand(time(0)); cin >> n >> k; for (int i = 1; i <= n; ++i) cin >> xa[i] >> ya[i] >> xb[i] >> yb[i]; vi bad, good, order; for (int i = 1; i <= n; ++i) bad.pb(i); while (1) { cerr << sz(good) << ' ' << sz(bad) << endl; order.clear(); random_shuffle(all(bad)); for (int j = 1; j <= k; ++j) { xa[j + n] = ya[j + n] = 1; yb[j + n] = xb[j + n] = inf; } for (auto x : bad) order.pb(x); for (auto x : good) order.pb(x); bad.clear(); good.clear(); for (auto i : order) { bool found = 0; for (int j = 1; j <= k; ++j) if (inter(xa[i], xb[i], xa[j + n], xb[j + n]) && inter(ya[i], yb[i], ya[j + n], yb[j + n])) { found = 1; xa[j + n] = max(xa[j + n], xa[i]); ya[j + n] = max(ya[j + n], ya[i]); xb[j + n] = min(xb[j + n], xb[i]); yb[j + n] = min(yb[j + n], yb[i]); break; } int j = 2; if (!found) bad.pb(i); else good.pb(i); } if (!sz(bad)) { for (int j = 1; j <= k; ++j) cout << xa[j + n] << ' ' << ya[j + n] << endl; return 0; } } }

Compilation message (stderr)

hamburg.cpp:50:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   50 | main () {
      |       ^
hamburg.cpp: In function 'int main()':
hamburg.cpp:92:8: warning: unused variable 'j' [-Wunused-variable]
   92 |    int j = 2;
      |        ^
#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...