QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#333784#7804. Intersegment Activationyhk1001TL 0ms0kbC++141.4kb2024-02-20 15:43:022024-02-20 15:43:03

Judging History

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

  • [2024-02-20 15:43:03]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-02-20 15:43:02]
  • 提交

answer

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

// #define Debug
// #define LOCAL
// #define TestCases

const int N = 10;

int n;

vector<int> s[N + 5];
void init()
{
	s[1].push_back(0), s[1].push_back(1);
	for (int i = 2; i <= n; i++)
	{
		s[i] = s[i - 1];
		for (auto it = s[i - 1].rbegin(); it != s[i - 1].rend(); it++)
			s[i].push_back((*it) | (1 << (i - 1)));
	}
	return ;
}

int get_num()
{
	int k;
	cin >> k;
	if (k == n)
		exit(0);
	return k;
}

void solve()
{
	cin >> n;
	init();

	int bef = get_num();
	for (int t = n; t > 0; t--)
	{
		cout << t << " " << t << endl;
		int cur = get_num();

		if (cur > bef)
		{
			cout << t << " " << t << endl;
			cur = get_num();
		}
		bef = get_num();
	}

	for (int t = n; t > 0; t--)
	{
		int lst = 0;
		for (auto v : s[t])
		{
			if (v == lst)
				continue;

			int pos = __lg(lst ^ v) + 1;
			lst = v;
			cout << pos << " " << t << endl;
			
			int cur = get_num();
			if (cur == bef)//no change
				continue;
			
			if (cur > bef)//better
			{
				bef = cur;
				break;
			}

			cout << pos << " " << t << endl;//worse
			bef = get_num();
			break;
		}
	}
	return ;
}

int main()
{
	#ifdef LOCAL
	freopen("data.in", "r", stdin);
	freopen("mycode.out", "w", stdout);
	#endif
	
	int T = 1;
	
	#ifdef TestCases
	scanf("%d", &T);
	#endif
	
	while (T--)
		solve();
	return 0;
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

3
0
0

output:

3 3

result: