Codeforces Round 1046 (Div. 2)
E
判断边双联通分量里面是否有奇环只需要二分图染色即可。
F
这个题涉及算上取整和下取整的问题,这类问题都可以通过把 \(\lfloor \frac{n}{k} \rfloor\) 转化为 \(t<\frac{n}{k} \leq t + 1\) 来推式子求出。但是本题数据少,也可以直接暴力做。
难点主要在于对 B 和 n 的值的计算,如果 n 太小就会导致 res * 2 太大无法通过。
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5, B = 116, n = 11343;
#define ll long long
int a[N];
int que(int k) {
cout << "? " << k << ' ';
for (int i = 1; i <= k; i++) cout << a[i] << ' ';
cout << endl;
int res; cin >> res;
return res;
}
void solve() {
for (int i = 1; i <= n; i++) a[i] = B;
int res = que(n);
if (!res) {
for (int i = 1; i <= B * B; i++) a[i] = 1;
res = que(B * B);
for (int i = 1; i < B; i++)
if ((B*B+i-1)/i == res) {
cout << "! " << i << endl;
break;
}
} else {
int wl = 0, wr;
for (int i = B; i <= 100000; i++) {
int x = i / B;
int l = (res - 1) * x + 1, r = res * x;
if (l <= n && r >= n) {
if (!wl) wl = wr = i;
else wr = i;
}
}
// cout << " ???" << wl << ' ' << wr << endl;
if (wl == wr) return cout << "! " << wl << endl, void();
int j = 0;
for (int i = 1; i <= wr - wl; i++) {
a[++j] = wl;
a[++j] = i;
}
res = que(j);
cout << "! "<<wl + j - res << endl;
}
}
int main() {
int t=1;
cin >> t;
while(t--) solve();
}

浙公网安备 33010602011771号