Submission #638850

# Submission time Handle Problem Language Result Execution time Memory
638850 2022-09-07T16:54:00 Z ShirleyM Treasure (different grader from official contest) (CEOI13_treasure2) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "treasure.h"
using namespace std;
#define int int64_t
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vvvi> vvvvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define x first
#define y second
#define pb push_back
#define loop(i,s,e) for(int i=s;i<e;i++)
#define loopr(i,s,e) for(int i=e-1;i>=s;i--)
#define chkmax(a,b) a=max(a,b)
#define chkmin(a,b) a=min(a,b)
#define all(a) a.begin(),a.end()
#define fast {ios_base::sync_with_stdio(false); cin.tie(0);}
const int inf = 1e18;
const int INF = 1e9;
const int mx_n = 100;

int n;
vii tr;
vvb grid;
vvb orig;
vvi dp;
int midr, midc;
int ans[mx_n+1][mx_n+1][mx_n+1][mx_n+1];
int cnt=0;

void print_grid(){
    loop(i,1,n+1){
        loop(j,1,n+1){
            if(grid[i][j]) Report(i, j);;
        }
    }
}

void prep_ans(){
    orig.resize(n+1,vb(n+1));
    loop(i,1,n+1) {
        string s; cin >>s;
        loop(j, 1, n + 1) {
            orig[i][j] = s[j-1]-'0';
        }
    }
    dp.resize(n+1, vi(n+1));
    loop(i, 1, n + 1) loop(j, 1, n + 1) dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + orig[i][j];

}

int ask(int i1, int j1, int i2, int j2){
    if(i2 < i1 || j2 < j1) return 0;
    if(i1<=0 || i1>n || i2<=0 || i2>n || j1<=0 || j1>n || j2<=0 || j2>n){
        cout << "failed";
        exit(1);
    }
    if(ans[i1][j1][i2][j2] == -1){
        //cout << i1 << " " << j1 << " " << i2 << " " << j2 << endl;
        //cout.flush();
        ans[i1][j1][i2][j2] = countTreasure(i1,j1,i2,j2);
        cnt++;
        //ans[i1][j1][i2][j2] = dp[i2][j2] - dp[i2][j1 - 1] - dp[i1 - 1][j2] + dp[i1 - 1][j1 - 1];
        //cin >> ans[i1][j1][i2][j2];
    }
    return ans[i1][j1][i2][j2];
}

void query(int r, int c){
    int cur;
    if(r<=midr){
        if(c<=midc){
            cur = ask(r,c,n,n) - ask(r+1,c,n,n) - ask(r,c+1,n,n) + ask(r+1,c+1,n,n);
        }else{
            cur = ask(r,1,n,c) - ask(r+1,1,n,c) - ask(r,1,n,c-1) + ask(r+1,1,n,c-1);
        }
    }
    else{
        if(c<=midc){
            cur = ask(1,c,r,n) - ask(1,c,r-1,n) - ask(1,c+1,r,n) + ask(1,c+1,r-1,n);
        }else{
            cur = ask(1,1,r,c) - ask(1,1,r-1,c) - ask(1,1,r,c-1) + ask(1,1,r-1,c-1);
        }
    }
    grid[r][c] = cur;
}

void findTreasure(int N){
fast;
    //cin >> n;
    n=N;
    //prep_ans();
    midr = midc = n/2;
    grid.resize(n+1, vb(n+1));
    loop(i1,1,n+1) loop(j1,1,n+1) loop(i2,1,n+1) loop(j2,1,n+1) ans[i1][j1][i2][j2] = -1;
    loop(i,1,n+1){
        loop(j,1,n+1){
            query(i,j);
        }
    }
    cout << "END\n";
    cout.flush();
    print_grid();
    /*loop(i,1,n+1){
        loop(j,1,n+1){
            if(grid[i][j] != orig[i][j]) {
                cout << "failed";
                exit(1);
            }
        }
    }*/
    if(cnt > n*n*n*n) exit(1);
}

Compilation message

/usr/bin/ld: /tmp/ccAQdUwV.o: in function `main':
grader.c:(.text.startup+0x103): undefined reference to `findTreasure(int)'
collect2: error: ld returned 1 exit status