Submission #321225

# Submission time Handle Problem Language Result Execution time Memory
321225 2020-11-11T15:12:48 Z monus1042 Treasure (different grader from official contest) (CEOI13_treasure2) C++17
Compilation error
0 ms 0 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, right, left;

int askit(int r1, int c1, int r2, int c2){
	return countTreasure(r1, c1, r2, c2);
}

int f(vector< pair<int,int> > v, int r, int c, int N){
	int result = 0, knew = 0, red = 0, want = 0;
	if (v[3].second == 'A'){
		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[3].second == 'B'){
		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[3].second == 'C'){
		for (int i=1; i<=r-1; i++){
			for (int j=c+1; j<=N; j++){
				knew += ans[i][j];
			}
		}
		knew = right - 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 = left - 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++){
		VER[i] = askit(1, 1, i, N);
		HOR[i] = askit(1, 1, N, i);
	}
	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];
			
			right = HOR[N] - HOR[j];
			left = HOR[j];

			vector< pair<int, int> > srt;
			int dx, dy;
			dx = j, dy = i;
			srt.pb(ii(dx*dy, 'A'));
			dx = N - j, dy = i;
			srt.pb(ii(dx*dy, 'B'));
			dx = N - j, dy = N - i;
			srt.pb(ii(dx*dy, 'C'));
			dx = j, dy = N - i;
			srt.pb(ii(dx*dy, 'D'));

			sort(srt.begin(), srt.end());
		    ans[i][j] = f(srt, 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 'int f(std::vector<std::pair<int, int> >, int, int, int)':
treasure.cpp:45:10: error: reference to 'right' is ambiguous
   45 |   knew = right - knew;
      |          ^~~~~
In file included from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from treasure.cpp:2:
/usr/include/c++/9/bits/ios_base.h:1014:3: note: candidates are: 'std::ios_base& std::right(std::ios_base&)'
 1014 |   right(ios_base& __base)
      |   ^~~~~
treasure.cpp:9:27: note:                 'int right'
    9 | int area, included, line, right, left;
      |                           ^~~~~
treasure.cpp:56:10: error: reference to 'left' is ambiguous
   56 |   knew = left - knew;
      |          ^~~~
In file included from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from treasure.cpp:2:
/usr/include/c++/9/bits/ios_base.h:1006:3: note: candidates are: 'std::ios_base& std::left(std::ios_base&)'
 1006 |   left(ios_base& __base)
      |   ^~~~
treasure.cpp:9:34: note:                 'int left'
    9 | int area, included, line, right, left;
      |                                  ^~~~
treasure.cpp: In function 'void findTreasure(int)':
treasure.cpp:86:4: error: reference to 'right' is ambiguous
   86 |    right = HOR[N] - HOR[j];
      |    ^~~~~
In file included from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from treasure.cpp:2:
/usr/include/c++/9/bits/ios_base.h:1014:3: note: candidates are: 'std::ios_base& std::right(std::ios_base&)'
 1014 |   right(ios_base& __base)
      |   ^~~~~
treasure.cpp:9:27: note:                 'int right'
    9 | int area, included, line, right, left;
      |                           ^~~~~
treasure.cpp:87:4: error: reference to 'left' is ambiguous
   87 |    left = HOR[j];
      |    ^~~~
In file included from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from treasure.cpp:2:
/usr/include/c++/9/bits/ios_base.h:1006:3: note: candidates are: 'std::ios_base& std::left(std::ios_base&)'
 1006 |   left(ios_base& __base)
      |   ^~~~
treasure.cpp:9:34: note:                 'int left'
    9 | int area, included, line, right, left;
      |                                  ^~~~