Submission #1166569

#TimeUsernameProblemLanguageResultExecution timeMemory
1166569NxmkxingAliens (IOI16_aliens)C++20
0 / 100
0 ms328 KiB
#include "aliens.h" #include <bits/stdc++.h> using namespace std; using ll = long long; using pll = pair<long long, long long>; const ll inf = 1e18; const int N = 1e5 + 10; const int M = 1e6 + 10; ll n, f[N], mx, minR[M], bestR[M], mxC[M], bestC[M], x[N], y[N], dp[N]; vector<pll> v, a; ll take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) { for (int i = 0; i < n; i++) if (r[i] > c[i]) swap(r[i], c[i]); for (int i = 0; i < n; i++) v.push_back({r[i], c[i]}); sort(v.begin(), v.end()); v.resize(unique(v.begin(), v.end()) - v.begin()); n = v.size(); //for (auto [x, y] : v) cout << x << " " << y << "\n"; for (int i = 0; i < m; i++) minR[i] = m; for (int i = 0; i < m; i++) mxC[i] = bestR[i] = bestC[i] = -1; for (int i = 0; i < n; i++) { auto [x, y] = v[i]; if (minR[y] > x) minR[y] = x, bestR[y] = i; if (mxC[x] < y) mxC[x] = y, bestC[x] = i; } //for (int i = 0; i < m; i++) cout << bestR[i] << " "; cout << "\n"; //for (int i = 0; i < m; i++) cout << bestC[i] << " "; cout << "\n"; for (int i = 0; i < m; i++) if (bestR[i] != -1) f[bestR[i]]++; for (int i = 0; i < m; i++) if (bestC[i] != -1) f[bestC[i]]++; //for (int i = 0; i < n; i++) cout << f[i] << " "; cout << "\n"; v.clear(); mx = -1; for (int i = 0; i < n; i++) if (f[i] == 2) a.push_back({v[i].first, v[i].second}); //for (auto [x, y] : a) cout << x << " " << y << "\n"; sort(a.begin(), a.end()); n = a.size(); for (int i = 0; i < n; i++) f[i] = 0; for (int i = 0; i < n; i++) { auto [x, y] = a[i]; if (mx < y) mx = y, f[i] = 1; } v.clear(); for (int i = 0; i < n; i++) if (f[i]) v.push_back({a[i].first, a[i].second}); n = v.size(); ::n = n; for (int i = 1; i <= n; i++) x[i] = v[i-1].first, y[i] = v[i-1].second; //cout << "\n" << n << "\n"; for (int i = 1; i <= n; i++) cout << x[i] << " " << y[i] << "\n"; // solve for (int i = 1; i <= n; i++) dp[i] = inf; for (int i = 1; i <= n; i++) for (int j = 1; j <= i; j++) dp[i] = min(dp[i], dp[j-1] + (y[i] - x[j] + 1) * (y[i] - x[j] + 1)); //for (int i = 1; i <= n; i++) cout << dp[i] << " "; return dp[n]; }

Compilation message (stderr)

aliens.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
aliens_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#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...