Submission #474789

# Submission time Handle Problem Language Result Execution time Memory
474789 2021-09-19T19:32:08 Z robell Treasure (different grader from official contest) (CEOI13_treasure2) C++17
Compilation error
0 ms 0 KB
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef long long ll;
#define pb push_back
#define eb emplace_back
#define countbits __builtin_popcount
#define beg0 __builtin_clz
#define terminal0 __builtin_ctz
#define mod 1e9+7
void setIO(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}
void setIO(string f){
	freopen((f+".in").c_str(),"r",stdin);
	freopen((f+".out").c_str(),"w",stdout);
	setIO();
}
int N;
vector<pair<int,int>> spots;
void grid(int bx, int by, int ux, int uy){
	cout << bx << " " << by << " " << ux << " " << uy << endl;
	int cells; cin >> cells;
	if (cells==0) return;
	if (bx>=ux && by>=uy){
		spots.pb({bx,by});return;
	}
	if ((bx-ux)%2==0){
		grid(bx,by,(ux+bx)/2,(uy+by)/2);//top left subgrid
		grid((ux+bx)/2,by,ux,(uy+by)/2);//top right subgrid
		grid(bx,(uy+by)/2,(ux+bx)/2,uy);//bottom left subgrid
		grid((ux+bx)/2,(uy+by)/2,ux,uy);//bottom right subgrid
	}else{
		grid(bx,by,(ux+bx)/2,(uy+by)/2);
		grid((ux+bx)/2+1,by,ux,(uy+by)/2);
		grid(bx,(uy+by)/2+1,(ux+bx)/2,uy);
		grid((ux+bx)/2+1,(uy+by)/2+1,ux,uy);
	}
}
int main(){
	setIO();
	cin >> N;
	grid(1,1,N,N);
	set<pair<int,int>> ans;
	bool grid[N][N];
	for (int i=0;i<N;i++){
		ans.insert(spots[i]);
	}
	for (pair<int,int> b:ans){
		grid[b.first-1][b.second-1]=true;
	}
	for (int i=0;i<N;i++){
		for (int j=0;j<N;j++){
			cout << grid[i][j];
		}
		cout << endl;
	}
}

Compilation message

treasure.cpp: In function 'void setIO(std::string)':
treasure.cpp:19:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |  freopen((f+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
treasure.cpp:20:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |  freopen((f+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccUTeKcE.o: in function `main':
treasure.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccjmfX3B.o:grader.c:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccjmfX3B.o: in function `main':
grader.c:(.text.startup+0x103): undefined reference to `findTreasure(int)'
collect2: error: ld returned 1 exit status