Submission #44932

# Submission time Handle Problem Language Result Execution time Memory
44932 2018-04-09T14:58:12 Z nibnalin Go, Gopher! (GCJ18Q_gogopher) C++17
30 / 30
103 ms 4284 KB
#include <iostream>
#include <cstdio>
#include <vector>
#include <fstream>
using namespace std;

const int maxn = int(1e3)+5;

int marker[maxn][maxn], done = 0;

pair<int, int> ask(pair<int, int>& cen)
{
	fflush(stdout), fflush(stdin);
	pair<int, int> ret;
	printf("%d %d\n", cen.first, cen.second);
	fflush(stdout), fflush(stdin);
	scanf("%d%d", &ret.first, &ret.second);
	fflush(stdout), fflush(stdin);
	if(ret.first == 0) done = 1;
	else if(ret.first == -1) exit(17);
	return ret;
}

bool rowdone(int r)
{
	return (marker[r][1] && marker[r][2] && marker[r][3]);
}

void solve()
{
	done = 0;
	for(int i = 0;i < maxn;i++)
	{
		for(int j = 0;j < maxn;j++) marker[i][j] = 0;
	}
	pair<int, int> center = {2, 2};
	int A;
	fflush(stdout), fflush(stdin);
	scanf("%d", &A);
	fflush(stdout), fflush(stdin);

	while(!done)
	{
		pair<int, int> col = ask(center);
		marker[col.first][col.second] = 1;
		if(rowdone(center.first-1)) center.first++;
	}
}

int main(void)
{
	int t;
	scanf("%d", &t);
	while(t--) solve();
}

Compilation message

gogopher.cpp: In function 'std::pair<int, int> ask(std::pair<int, int>&)':
gogopher.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &ret.first, &ret.second);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gogopher.cpp: In function 'void solve()':
gogopher.cpp:39:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &A);
  ~~~~~^~~~~~~~~~
gogopher.cpp: In function 'int main()':
gogopher.cpp:53:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &t);
  ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 30 ms 4264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 103 ms 4284 KB Output is correct