Submission #871354

#TimeUsernameProblemLanguageResultExecution timeMemory
871354vjudge1Quality Of Living (IOI10_quality)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define pb push_back #define fi first #define se second #define faster ios_base::sync_with_stdio(0); cin.tie(0); #define int long long using namespace std; using lli = long long; using ld = long double; using pii = pair <int, int>; mt19937_64 Rand(chrono::steady_clock::now().time_since_epoch().count()); const int maxn = 2e3 + 1000; const int mod = 1e9 + 7; lli m, n, h, w, q[maxn][maxn], a[maxn][maxn], pre[maxn][maxn]; void ReadInput() { cin >> m >> n >> h >> w; for (lli i = 1; i <= m; i ++) { for (lli j = 1; j <= n; j ++) { cin >> q[i][j]; } } } bool check(lli x) { for (lli i = 1; i <= m; i ++) { for (lli j = 1; j <= n; j ++) { a[i][j] = 0; } } for (lli i = 1; i <= m; i ++) { for (lli j = 1; j <= n; j ++) { if (q[i][j] <= x) { a[i][j] = 1; } } } for (lli i = 1; i <= m; i ++) { for (lli j = 1; j <= n; j ++) { pre[i][j] = a[i][j] + pre[i][j - 1] + pre[i - 1][j] - pre[i - 1][j - 1]; //cout << pre[i][j] << endl; } } //cout << endl; for (lli i = 1; i <= m - h + 1; i ++) { for (lli j = 1; j <= n - w + 1; j ++) { lli sum = pre[i + h - 1][j + w - 1] - pre[i + h - 1][j - 1] - pre[i - 1][j + w - 1] + pre[i - 1][j - 1]; //cout << sum << endl; if (sum > (h * w - 1) / 2) { //cout << " " << 1; return true; } } } return false; } void Solve() { lli l = 1, r = m * n, res = 0; while (l <= r) { lli mid = (l + r) / 2; if (check(mid)) { res = mid; r = mid - 1; } else l = mid + 1; //cout << mid << endl; } cout << res; } #define debug #define taskname "A" signed main(){ faster if (fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } int tt = 1; //cin >> tt; while (tt--){ ReadInput(); Solve(); } if (fopen("timeout.txt", "r")){ ofstream timeout("timeout.txt"); timeout << signed(double(clock()) / CLOCKS_PER_SEC * 1000); timeout.close(); #ifndef debug cerr << "Time elapsed: " << signed(double(clock()) / CLOCKS_PER_SEC * 1000) << "ms\n"; #endif // debug } }

Compilation message (stderr)

quality.cpp: In function 'int main()':
quality.cpp:91:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   91 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
quality.cpp:92:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   92 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cc3AWjwL.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc7RyKyN.o:quality.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc3AWjwL.o: in function `main':
grader.cpp:(.text.startup+0xe9): undefined reference to `rectangle(int, int, int, int, int (*) [3001])'
collect2: error: ld returned 1 exit status