QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#126119#6668. Trokutihxhuoxinghx0 0ms0kbC++143.8kb2023-07-18 10:36:222023-07-18 10:36:25

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-18 10:36:25]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2023-07-18 10:36:22]
  • 提交

answer

#include <iostream>
#include <utility>
#include <random>
#include <ctime>
using namespace std;

//constexpr int NODECNT = 100;
//constexpr int FIRSTTRY = 2733;
//constexpr int QUERYCNT = 3399;

constexpr int NODECNT = 10;
constexpr int FIRSTTRY = 31;
constexpr int QUERYCNT = 40;

struct Query {
	int a, b, c;
	Query() = default;
	Query(int _a, int _b, int _c) {
		if(_a < _b && _b < _c) a = _a, b = _b, c = _c;
		if(_a < _c && _c < _b) a = _a, b = _c, c = _b;
		if(_b < _a && _a < _c) a = _b, b = _a, c = _c;
		if(_b < _c && _c < _a) a = _b, b = _c, c = _a;
		if(_c < _a && _a < _b) a = _c, b = _a, c = _b;
		if(_c < _b && _b < _a) a = _c, b = _b, c = _a;
	}
	bool operator==(const Query& rhs) const {
		return a == rhs.a && b == rhs.b && c == rhs.c;
	}
	int ask()
	{
		cout << "? " << a + 1 << " " << b + 1 << " " << c + 1 << endl;
		int res;
		cin >> res;
		return res;
	}
};

vector<pair<Query, int> > query;

int ans[NODECNT][NODECNT];

void check(Query q, int res)
{
	if(res == 0)
	{
		ans[q.a][q.b] = ans[q.b][q.a] = ans[q.a][q.c] = ans[q.c][q.a] = ans[q.b][q.c] = ans[q.c][q.b] = 0;
	}
	if(res == 3)
	{
		ans[q.a][q.b] = ans[q.b][q.a] = ans[q.a][q.c] = ans[q.c][q.a] = ans[q.b][q.c] = ans[q.c][q.b] = 1;
	}
	if(res == 1)
	{
		if(ans[q.a][q.b] == 0 && ans[q.a][q.c] == 0) ans[q.b][q.c] = ans[q.c][q.b] = 1;
		if(ans[q.a][q.b] == 0 && ans[q.b][q.c] == 0) ans[q.a][q.c] = ans[q.c][q.a] = 1;
		if(ans[q.a][q.c] == 0 && ans[q.b][q.c] == 0) ans[q.a][q.b] = ans[q.b][q.a] = 1;
		if(ans[q.a][q.b] == 1) ans[q.a][q.c] = ans[q.c][q.a] = ans[q.b][q.c] = ans[q.c][q.b] = 0;
		if(ans[q.a][q.c] == 1) ans[q.a][q.b] = ans[q.b][q.a] = ans[q.b][q.c] = ans[q.c][q.b] = 0;
		if(ans[q.b][q.c] == 1) ans[q.a][q.b] = ans[q.b][q.a] = ans[q.a][q.c] = ans[q.c][q.a] = 0;
	}
	if(res == 2)
	{
		if(ans[q.a][q.b] == 1 && ans[q.a][q.c] == 1) ans[q.b][q.c] = ans[q.c][q.b] = 0;
		if(ans[q.a][q.b] == 1 && ans[q.b][q.c] == 1) ans[q.a][q.c] = ans[q.c][q.a] = 0;
		if(ans[q.a][q.c] == 1 && ans[q.b][q.c] == 1) ans[q.a][q.b] = ans[q.b][q.a] = 0;
		if(ans[q.a][q.b] == 0) ans[q.a][q.c] = ans[q.c][q.a] = ans[q.b][q.c] = ans[q.c][q.b] = 1;
		if(ans[q.a][q.c] == 0) ans[q.a][q.b] = ans[q.b][q.a] = ans[q.b][q.c] = ans[q.c][q.b] = 1;
		if(ans[q.b][q.c] == 0) ans[q.a][q.b] = ans[q.b][q.a] = ans[q.a][q.c] = ans[q.c][q.a] = 1;
	}
}

mt19937 rand_e;

int main()
{
	for(int i = 0; i < NODECNT; i++)
	{
		for(int j = 0; j < NODECNT; j++)
		{
			ans[i][j] = -1;
		}
	}
	rand_e.seed(time(0));
	for(int i = 0; i < FIRSTTRY; i++)
	{
		bool flag = true;
		Query q;
		while(flag)
		{
			q = Query(rand_e() % NODECNT, rand_e() % NODECNT, rand_e() % NODECNT);
			if(q.a == q.b || q.a == q.c || q.b == q.c) continue;
			flag = false;
			for(pair<Query, int> pqi : query)
			{
				if(q == pqi.first)
				{
					flag = true;
					break;
				}
			}
		}
		query.push_back({q, q.ask()});
	}
	for(pair<Query, int> pqi : query)
	{
		check(pqi.first, pqi.second);
	}
	for(pair<Query, int> pqi : query)
	{
		check(pqi.first, pqi.second);
	}
	for(int i = FIRSTTRY; i < QUERYCNT; i++)
	{
		bool flag = true;
		Query q;
		while(flag)
		{
			q = Query(rand_e() % NODECNT, rand_e() % NODECNT, rand_e() % NODECNT);
			if(q.a == q.b || q.a == q.c || q.b == q.c) continue;
			if(ans[q.a][q.b] != -1 && ans[q.a][q.c] != -1 && ans[q.b][q.c] != -1) continue;
			flag = false;
			for(pair<Query, int> pqi : query)
			{
				if(q == pqi.first)
				{
					flag = true;
					break;
				}
			}
		}
		query.push_back({q, q.ask()});
		check(q, query.back().second);
		for(pair<Query, int> pqi : query)
		{
			check(pqi.first, pqi.second);
		}
	}
	cout << "!" << endl;
	for(int i = 0; i < NODECNT; i++)
	{
		for(int j = 0; j < NODECNT; j++)
		{
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
}

详细

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

input:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

output:

? 3 6 10
? 1 6 10
? 6 7 10
? 4 7 8
? 2 8 9
? 4 8 9
? 4 6 10
? 1 2 4
? 1 5 7
? 2 6 8
? 5 7 8
? 3 4 6
? 1 3 10
? 2 9 10
? 2 4 10
? 2 3 8
? 2 5 7
? 1 2 6
? 1 7 9
? 1 4 8
? 1 3 6
? 1 2 10
? 2 3 10
? 6 8 10
? 3 5 9
? 1 7 10
? 3 8 9
? 2 6 10
? 7 8 10
? 1 2 8
? 2 3 6
? 3 5 6
? 4 6 9
? 3 7 9
? 5 6 10
? 4 5 10

result: