QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#333780#7804. Intersegment Activationyhk1001WA 1ms3704kbC++141.2kb2024-02-20 15:37:082024-02-20 15:37:08

Judging History

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

  • [2024-02-20 15:37:08]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3704kb
  • [2024-02-20 15:37:08]
  • 提交

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--)
	{
		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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3688kb

input:

3
0
0
0
1
3

output:

1 3
2 3
1 3
1 2

result:

ok OK, 4 queries

Test #2:

score: 0
Accepted
time: 0ms
memory: 3704kb

input:

1
0
1

output:

1 1

result:

ok OK, 1 queries

Test #3:

score: 0
Accepted
time: 1ms
memory: 3692kb

input:

2
1
0
1
2

output:

1 2
1 2
1 1

result:

ok OK, 3 queries

Test #4:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

2
0
0
1
2

output:

1 2
2 2
1 1

result:

ok OK, 3 queries

Test #5:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

2
0
0
0
1
2

output:

1 2
2 2
1 2
1 1

result:

ok OK, 4 queries

Test #6:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

2
0
2

output:

1 2

result:

ok OK, 1 queries

Test #7:

score: 0
Accepted
time: 0ms
memory: 3516kb

input:

3
0
1
2
3

output:

1 3
1 2
1 1

result:

ok OK, 3 queries

Test #8:

score: 0
Accepted
time: 1ms
memory: 3688kb

input:

3
0
0
0
0
0
1
1
2
3

output:

1 3
2 3
1 3
3 3
1 3
1 2
2 2
1 1

result:

ok OK, 8 queries

Test #9:

score: 0
Accepted
time: 1ms
memory: 3624kb

input:

3
0
0
0
0
0
0
0
1
1
1
2
3

output:

1 3
2 3
1 3
3 3
1 3
2 3
1 3
1 2
2 2
1 2
1 1

result:

ok OK, 11 queries

Test #10:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

3
0
3

output:

1 3

result:

ok OK, 1 queries

Test #11:

score: -100
Wrong Answer
time: 1ms
memory: 3688kb

input:

4
0
0
0
0
0
0
0
0
0
1
1
2
1
2
3

output:

1 4
2 4
1 4
3 4
1 4
2 4
1 4
4 4
1 4
1 3
2 3
1 2
1 2
1 1

result:

wrong answer format  Unexpected end of file - int32 expected