QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#333784 | #7804. Intersegment Activation | yhk1001 | TL | 0ms | 0kb | C++14 | 1.4kb | 2024-02-20 15:43:02 | 2024-02-20 15:43:03 |
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