Submission #284195

# Submission time Handle Problem Language Result Execution time Memory
284195 2020-08-27T02:10:32 Z FlashGamezzz Treasure (different grader from official contest) (CEOI13_treasure2) C++17
Compilation error
0 ms 0 KB
#include "treasure.h"
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>

using namespace std;
 
int psums[101][101] = {}, ul[101][101] = {}, dr[101][101] = {};

int treasure(int a1, int a2, int d){
	if (a1 == 2 || a2 == 2){
    	return 1;
    }
    if (a1 == 0 || a2 == 0){
    	return 0;
    }
    if (d == 2){
    	return -1;
    }
    if (d == 3){
    	return 0;
    }
    return 1;
}
void findTreasure (int N) {
	int h = (N+1)/2;
	for (int r = 1; r <= N; r++){
		for (int c = 1; c <= N; c++){
			bool a = (r > h), b = (c > h);
			if (a && b){
				psums[r][c] = countTreasure(1, 1, r, c);
			} else {
				if (a && c > 1){
					dr[r][c] = countTreasure(1, c, r, N);
				}
				if (b && r > 1){
					ul[r][c] = countTreasure(r, 1, N, c);
				}
			}
		}
	}
	for (int i = N; i > h; i--){
		ul[1][i] = psums[N][i];
		dr[i][1] = psums[i][N];
	}
	for (int r = N; r > h; r--){
		for (int c = 1; c < h; c++){
			psums[r][c] = psums[r][N]-dr[r][c+1];
		}
		psums[r][h] = countTreasure(1, 1, r, h);
	}
	for (int c = N; c > h; c--){
		for (int r = 1; r < h; r++){
			psums[r][c] = psums[N][c]-ul[r+1][c];
		}
		psums[h][c] = countTreasure(1, 1, h, c);
	}
	for (int r = h; r >= 1; r--){
		for (int c = h; c >= 1; c--){
        	if (r % 2 != 0 && c == 1){
            	continue;
			}
            if (c % 2 != 0 && r == 1){
            	continue;
			}
            psums[r][c] = countTreasure(r+1, c+1, N, N)-psums[N][N]+psums[N][c]+psums[r][N];
		}
	}
    for (int i = 1; i <= h; i+=2){
    	if (zero(psums[i][2]-psums[i-1][2], psums[i+1][1]-psums[i-1][1], psums[i+1][2]-psums[i-1][2]) == 0){
   			psums[i][1] = psums[i-1][1];
        } else if (zero(psums[i][2]-psums[i-1][2], psums[i+1][1]-psums[i-1][1], psums[i+1][2]-psums[i-1][2]) == 1){
        	psums[i][1] = psums[i-1]+1;
        } else {
        	psums[i][1] = countTreasure(i+1, 2, N, N)-psums[N][N]+psums[N][1]+psums[i][N];
        }
        if (zero(psums[2][i]-psums[2][i-1], psums[1][i+1]-psums[1][i-1], psums[2][i+1]-psums[2][i-1]) == 0){
        	psums[1][i] = psums[1][i-1];
        } else if (zero(psums[2][i]-psums[2][i-1], psums[1][i+1]-psums[1][i-1], psums[2][i+1]-psums[2][i-1]) == 1){
        	psums[1][i] = psums[1][i-1]+1;
        } else {
        	psums[1][i] = countTreasure(2, i+1, N, N)-psums[N][N]+psums[N][i+1]+psums[1][N];
        }
    }
	for (int r = 1; r <= N; r++){
		for (int c = 1; c <= N; c++){
			if (psums[r][c] == psums[r-1][c]+psums[r][c-1]-psums[r-1][c-1]+1){
				Report(r, c);
			}
		}
	}
}

Compilation message

treasure.cpp: In function 'void findTreasure(int)':
treasure.cpp:75:10: error: 'zero' was not declared in this scope
   75 |      if (zero(psums[i][2]-psums[i-1][2], psums[i+1][1]-psums[i-1][1], psums[i+1][2]-psums[i-1][2]) == 0){
      |          ^~~~
treasure.cpp:78:34: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   78 |          psums[i][1] = psums[i-1]+1;
      |                        ~~~~~~~~~~^~
      |                                  |
      |                                  int*
treasure.cpp:82:13: error: 'zero' was not declared in this scope
   82 |         if (zero(psums[2][i]-psums[2][i-1], psums[1][i+1]-psums[1][i-1], psums[2][i+1]-psums[2][i-1]) == 0){
      |             ^~~~