QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#260346 | #7804. Intersegment Activation | DoorKickers# | TL | 0ms | 0kb | C++20 | 3.6kb | 2023-11-22 02:59:06 | 2023-11-22 02:59:06 |
answer
#include <bits/stdc++.h>
#include <algorithm>
#include <cctype>
#include <climits>
#include <functional>
#include <iomanip>
#include <queue>
#include <set>
#include <valarray>
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define rep(a, b, c) for (int a = b; a <= c; a++)
#define per(a, b, c) for (int a = c; a >= b; a--)
#define all(a) a.begin() + 1, a.end()
#define all_(a) a.begin(), a.end()
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
int mod = 998244353;
ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll fp_m (ll a, ll n) {
a %= mod;
ll res = 1; while (n) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res;
}
ll fp (ll a, ll n) {
ll res = 1; while (n) { if (n & 1) res *= a; a *= a; n >>= 1; } return res;
}
ll inv(ll x) {return fp_m(x, mod - 2);}
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
os << "[";
for (size_t i = 0; i < vec.size(); ++i) {
os << vec[i];
if (i < vec.size() - 1)
os << ", ";
}
os << "]";
return os;
}
template<typename T, typename... Args>
void debug(std::string name, T value, Args &&...arg) {
std::cout << name;
(..., (std::cout << '[' << arg << ']'));
std::cout << " = " << value << '\n';
}
//中文测试 中文测试
signed main() {
std::ios::sync_with_stdio(0);
std::cin.tie(0); std::cout.tie(0);
int n; std::cin >> n;
std::map<std::pair<int, int>, int> mx;
std::map<std::pair<int, int>, int> now;
int max = 0;
std::cin >> max;
int cnt = 0;
for (int i = 1; i <= n; i++) {
std::function<void(int)> dfs = [&] (int layer) {
if (layer == n + 1) {
return;
}
dfs(layer + 1);
std::cout << i << ' ' << layer << '\n';
cnt++;
now[{i, layer}] = 1 - now[{i, layer}];
int K; std::cin >> K;
if (K == n) exit(0);
if (K > max) {
K = max;
mx = now;
}
dfs(layer + 1);
};
dfs(i);
// for (int j = 0; j <= (1 << (n - i + 1)) - 1; j++) {
// for (int k = i; k <= n; k++) {
// int x = (j >> (k - i)) & 1;
// if (now[{i, k}] != x) {
// cnt++;
// // std::cout << i << ' ' << k << '\n';
// std::cout.flush();
// now[{i, k}] = 1 - now[{i, k}];
// // int K; std::cin >> K;
// // if (K == n) {
// // return 0;
// // } else {
// // if (K > max) {
// // K = max;
// // mx = now;
// // }
// // }
// }
// }
// }
for (int k = i; k <= n; k++) {
if (now[{i, k}] != mx[{i, k}]) {
std::cout << i << ' ' << k << '\n';
cnt++;
std::cout.flush();
now[{i, k}] = 1 - now[{i, k}];
int K; std::cin >> K;
if (K == n) return 0;
}
}
}
return 0;
}
//出题是2^n = 11111 + 1
/*
1 2 3 4 5 6
[1, 1]
[2, 2]
[3, 3]
[4, 2]
[5, 1]
[6, 1]
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
3 0