제출 #78728

#제출 시각아이디문제언어결과실행 시간메모리
78728Plurm보물 찾기 (CEOI13_treasure2)C++11
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
int knownval[128][128];
class Hasher{
public:
	const size_t operator()(const tuple<int,int,int,int>& x) const{
		return get<0>(x) + get<1>(x) + get<2>(x) + get<3>(x);
	}
};
int query(int a,int b,int c,int d){
	printf("%d %d %d %d\n",a,b,c,d);
	fflush(stdout);
	int x;
	scanf("%d",&x);
	return x;
}
unordered_map<tuple<int,int,int,int>,int,Hasher> cache;
int n;
int getval(int a,int b,int c,int d){
	if(c == 0 || d == 0 || a == n+1 || b == n+1) return 0;
	if(cache.find(make_tuple(a,b,c,d)) == cache.end()){
		int res = query(a,b,c,d);
		cache[make_tuple(a,b,c,d)] = res;
		return res;
	}else{
		return cache[make_tuple(a,b,c,d)];
	}
}
int main(){
	memset(knownval,-1,sizeof(knownval));
	scanf("%d",&n);
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(i*j > n*n/2){
				knownval[i][j] = getval(1,1,i,j) - getval(1,1,i-1,j) - getval(1,1,i,j-1) + getval(1,1,i-1,j-1);
			}else{
				knownval[i][j] = getval(i,j,n,n) - getval(i+1,j,n,n) - getval(i,j+1,n,n) + getval(i+1,j+1,n,n);
			}
		}
	}
	printf("END\n");
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			printf("%d",knownval[i][j]);
		}
		printf("\n");
	}
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

treasure.cpp: In function 'int query(int, int, int, int)':
treasure.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&x);
  ~~~~~^~~~~~~~~
treasure.cpp: In function 'int main()':
treasure.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
/tmp/ccVoum31.o: In function `main':
treasure.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccOS84ke.o:grader.c:(.text.startup+0x0): first defined here
/tmp/ccOS84ke.o: In function `main':
grader.c:(.text.startup+0x109): undefined reference to `findTreasure(int)'
collect2: error: ld returned 1 exit status