Submission #501083

# Submission time Handle Problem Language Result Execution time Memory
501083 2022-01-02T10:45:46 Z beaconmc Quality Of Living (IOI10_quality) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
using namespace std;


int pos[9000001][2];
int pref[3001][3001];
int r,c,h,w;


bool check(int x){
    FOR(i,0,3001){
        FOR(j,0,3001){
            pref[i][j] = 0;
        }
    }
    FOR(i,1,x+1){
        int a = pos[i][0]; int b=pos[i][1];
        FORNEG(j,a,max(-1, a-h)){
            pref[j][b+1] -= 1;
        }
        b = max(0, b-(w-1));
        FORNEG(j,a,max(-1, a-h)){
            pref[j][b] += 1;
        }
    }
    FOR(i,0,r-h+1){
        if (pref[i][0] > int(h*w/2)) return true;
        FOR(j,1,c-w+1){
            pref[i][j] += pref[i][j-1];
            if (pref[i][j]> int(h*w/2)) return true;
        }
    }
    return false;
    
}


int rectangle(int R, int C, int H, int W, int Q[3001][3001]) {
    r = R; c = C; h = H; w = W;
    FOR(i,0,R){
        FOR(j,0,C){
            pos[Q[i][j]][0] = i;
            pos[Q[i][j]][1] = j;
        }
    }

    int lo = 0;
    int hi = int(R*C/2)+1;
    while (lo < hi) {
		int mid = lo + (hi - lo) / 2;
		if (check(mid)) {
			hi = mid;
		} else {
			lo = mid + 1;
		}
	}
	return lo;
}

int Q[3001][3001];
int main(){
    cin.tie(0)->sync_with_stdio(0);
    freopen("input.txt", "r", stdin);
    int R,C,H,W;
    cin >> R >> C >> H >> W;
    r = R; c = C; h = H; w = W;
    FOR(i,0,R){
        FOR(j,0,C){
            cin >> Q[i][j];
        }
    }
    FOR(i,0,R){
        FOR(j,0,C){
            pos[Q[i][j]][0] = i;
            pos[Q[i][j]][1] = j;
        }
    }

    //cout << rectangle(R,C,H,W,Q);
}

Compilation message

quality.cpp: In function 'int main()':
quality.cpp:66:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |     freopen("input.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccpWXq8L.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccJUVsGL.o:quality.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status