Submission #342997

# Submission time Handle Problem Language Result Execution time Memory
342997 2021-01-03T10:36:55 Z chon Treasure (different grader from official contest) (CEOI13_treasure2) C++14
44 / 100
24 ms 1004 KB
#include "treasure.h"
#include <bits/stdc++.h>
 
 
 
 
using namespace std;
#define pb push_back
#define ii pair<int,int>
 
int ans[105][105];
int HOR[105], VER[105];
int area, included, line, ri, le;
 
map< tuple<int, int, int, int>, int > dp;
 
int askit(int r1, int c1, int r2, int c2) {
	tuple<int, int, int, int> tup(r1, c1, r2, c2);
	if (dp.find(tup) != dp.end()) return dp[tup];
	return dp[tup] = countTreasure(r1, c1, r2, c2);
}
 
 
int f(int v, int r, int c, int N) {
	int result = 0, knew = 0, red = 0, want = 0;
	if (v == 0) {
		for (int i = 1; i <= r - 1; i++) {
			for (int j = 1; j <= c; j++) {
				knew += ans[i][j];
			}
		}
		red = askit(1, 1, r, c);
		want = red - knew;
 
		knew = 0;
		for (int j = 1; j <= c - 1; j++) knew += ans[r][j];
		result = want - knew;
	}
	else if (v==1) {
		for (int i = 1; i <= r - 1; i++) {
			for (int j = c + 1; j <= N; j++) {
				knew += ans[i][j];
			}
		}
		if (c + 1 <= N) red = askit(1, c + 1, r, N);
		want = red - knew;
 
		result = included - want;
	}
	else if (v == 2) {
		for (int i = 1; i <= r - 1; i++) {
			for (int j = c + 1; j <= N; j++) {
				knew += ans[i][j];
			}
		}
		knew = ri - knew;
		if (c + 1 <= N && r + 1 <= N) red = askit(r + 1, c + 1, N, N);
 
		want = knew - red;
		result = included - want;
	}
	else { // D
		for (int i = 1; i <= r - 1; i++) {
			for (int j = 1; j <= c; j++) {
				knew += ans[i][j];
			}
		}
		knew = le - knew;
		if (r + 1 <= N) red = askit(r + 1, 1, N, c);
 
		want = knew - red;
		knew = 0;
		for (int j = 1; j <= c - 1; j++) knew += ans[r][j];
		result = want - knew;
	}
	return result;
}
 
void findTreasure(int N) {
	//int cnt = countTreasure(1, 1, N, N);
	//if(cnt > 0) Report (1, 1);
	area = askit(1, 1, N, N);
	for (int i = 1; i <= N - 1; i++) {
		if (i > (N - i)) VER[i] = askit(1, 1, i, N);
		else VER[i] = area - askit(i + 1, 1, N, N);
	}
	for (int i = 1; i <= N - 1; i++) {
		if (i > (N - i)) HOR[i] = askit(1, 1, N, i);
		else HOR[i] = area - askit(1, i + 1, N, N);
	}
	VER[N] = HOR[N] = area;
 
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			int below = VER[N] - VER[i];
			int sup = VER[i - 1];
			line = area - sup - below;
 
			included = line;
			for (int k = 1; k < j; k++) included -= ans[i][k];
 
			ri = HOR[N] - HOR[j];
			le = HOR[j];
 
			
			//vector< pair<int, int> > srt;
			int dx, dy;
			int data[4][2];
			int A, B, C, D;
			
			dx = j, dy = i;
			data[0][0] = dx * dy; 
          	data[0][1]=0;
 
			
			dx = N - j, dy = i;
			data[1][0] = dx * dy;
 			data[1][1]=1;
          
			dx = N - j, dy = N - i;
			data[2][0] = dx * dy;
			data[2][1]=2;
			dx = j, dy = N - i;
			data[3][0] = dx * dy;
 			data[3][1]=3;
          
			
 
			for (int a = 0; a < 4; a++)
			{
				for (int b = a + 1; b < 4; b++)
				{
					if (data[a][0] > data[b][0])
					{
                      	int temp;
						temp = data[a][0];
						data[a][0] = data[b][0];
						data[b][0] = temp;
					}
                  else if(data[a][0]==data[b][0] && data[a][1]<data[b][1])
                    {
						int temp;
						temp = data[a][0];
						data[a][0] = data[b][0];
						data[b][0] = temp;
					}
				}
			}
          ans[i][j]=f(data[3][1],i,j,N);
		}
	}
 
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			if (ans[i][j]) Report(i, j);
		}
	}
}

Compilation message

treasure.cpp: In function 'void findTreasure(int)':
treasure.cpp:109:8: warning: unused variable 'A' [-Wunused-variable]
  109 |    int A, B, C, D;
      |        ^
treasure.cpp:109:11: warning: unused variable 'B' [-Wunused-variable]
  109 |    int A, B, C, D;
      |           ^
treasure.cpp:109:14: warning: unused variable 'C' [-Wunused-variable]
  109 |    int A, B, C, D;
      |              ^
treasure.cpp:109:17: warning: unused variable 'D' [-Wunused-variable]
  109 |    int A, B, C, D;
      |                 ^
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 364 KB Output is partially correct - N = 5, K = 422, score = 8
2 Partially correct 1 ms 364 KB Output is partially correct - N = 10, K = 6979, score = 4
3 Partially correct 1 ms 364 KB Output is partially correct - N = 15, K = 36142, score = 4
4 Partially correct 1 ms 364 KB Output is partially correct - N = 16, K = 46855, score = 4
5 Partially correct 4 ms 620 KB Output is partially correct - N = 55, K = 6762772, score = 4
6 Partially correct 9 ms 620 KB Output is partially correct - N = 66, K = 14055755, score = 4
7 Partially correct 10 ms 748 KB Output is partially correct - N = 77, K = 26086868, score = 4
8 Partially correct 15 ms 876 KB Output is partially correct - N = 88, K = 44559019, score = 4
9 Partially correct 23 ms 1004 KB Output is partially correct - N = 99, K = 71450527, score = 4
10 Partially correct 24 ms 1004 KB Output is partially correct - N = 100, K = 74385049, score = 4