QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#579637 | #9223. Data Determination | wind_cross# | WA | 25ms | 4488kb | C++14 | 5.0kb | 2024-09-21 16:25:19 | 2024-09-21 16:25:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(n) for (int _i_i_ = (n); _i_i_; --_i_i_)
#define repf(i, st, ed) for (int i = (st); i < (ed); ++i)
#define repr(i, st, ed) for (int i = (st); i > (ed); --i)
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define mem(arr, x) memset((arr), x, sizeof (arr))
#define mkp make_pair
#define edge(y, x, ver) for (int _i_ = h[x], y = ver[_i_]; _i_; y = ver[_i_ = nxt[_i_]])
#define rand_init mt19937 rnd(chrono::system_clock::now().time_since_epoch().count())
#define setdb(v) setprecision(v)
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
class UF {
vector<int> p, rk, sz;
int cnt;
public:
UF() {}
UF(int n) {
cnt = n;
p.resize(n);
iota(p.begin(), p.end(), 0);
rk.resize(n);
sz.resize(n);
fill(sz.begin(), sz.end(), 1);
}
int find(int x) {
return x == p[x] ? x : p[x] = find(p[x]);
}
bool merge(int x, int y) {
int fx = find(x), fy = find(y);
if (fx == fy) return false;
--cnt;
if (rk[fx] > rk[fy]) swap(fx, fy);
p[fx] = fy;
sz[fy] += sz[fx];
if (rk[fx] == rk[fy]) ++rk[fy];
return true;
}
int size() {
return cnt;
}
int size(int i) {
return sz[i];
}
};
class BIT {
vector<ll> bit;
int mx;
public:
BIT() {}
BIT(int n) {
mx = n;
bit.resize(n + 1);
}
void upd(int i, ll x) {
for (; i <= mx; i += i & -i) bit[i] += x;
}
ll ask(int i) {
ll res = 0;
for (; i; i &= i - 1) res += bit[i];
return res;
}
};
class lazySGT {
vector<int> lt, rt;
vector<ll> dat, tag;
ll v;
void spread(int k) {
if (tag[k]) {
dat[k * 2 + 1] += tag[k];
dat[k * 2 + 2] += tag[k];
tag[k * 2 + 1] = tag[k * 2 + 2] = tag[k];
tag[k] = 0;
}
}
void build(vector<ll> &a, int k, int l, int r) {
lt[k] = l, rt[k] = r, dat[k] = a[l - 1];
if (l == r) return ;
int m = (l + r) >> 1;
build(a, k * 2 + 1, l, m), build(a, k * 2 + 2, m + 1, r);
dat[k] = dat[k * 2 + 1] + dat[k * 2 + 2];
}
void update(int k, int l, int r, ll v) {
if (l <= lt[k] && rt[k] <= r) {
dat[k] += v;
tag[k] = v;
return ;
}
if (r < lt[k] || rt[k] < l) {
return ;
}
spread(k);
update(k * 2 + 1, l, r, v), update(k * 2 + 2, l, r, v);
dat[k] = dat[k * 2 + 1] + dat[k * 2 + 2];
}
ll query(int k, int l, int r) {
if (l <= lt[k] && rt[k] <= r) {
return dat[k];
}
if (r < lt[k] || rt[k] < l) {
return 0;
}
spread(k);
return query(k * 2 + 1, l, r) + query(k * 2 + 2, l, r);
}
public:
lazySGT() {}
lazySGT(vector<ll> &a) {
int n = a.size();
lt.resize(n << 3), rt.resize(n << 3);
dat.resize(n << 3), tag.resize(n << 3);
fill(dat.begin(), dat.end(), v);
build(a, 0, 1, n);
}
void update(int l, int r, ll v) {
update(0, l, r, v);
}
ll query(int l, int r) {
return query(0, l, r);
}
};
class ST {
vector<vector<ll>> arr;
public:
ST() {}
ST(vector<ll> a) {
int n = a.size();
arr.push_back(a);
int k = 31 - __builtin_clz(n);
rep1 (i, k) {
arr.push_back(vector<ll>(n - (1 << i) + 1));
rep0 (j, n - (1 << i) + 1) {
arr[i][j] = min(arr[i - 1][j], arr[i - 1][j + (1 << (i - 1))]);
}
}
}
ll query(int l, int r) {
int i = 31 - __builtin_clz(r - l + 1);
return min(arr[i][l], arr[i][r - (1 << i) + 1]);
}
};
const int maxn = 2e5 + 5;
int n, k, m;
int a[maxn];
void init() {
}
void clear() {
}
void solve() {
cin >> n >> k >> m;
rep0 (i, n) cin >> a[i];
sort(a, a + n);
if (k % 2 == 1) {
int p = lower_bound(a, a + n, m) - a;
if (p < n && a[p] == m && p >= k / 2 && p < n - k / 2) {
cout << "TAK" << endl;
} else {
cout << "NIE" << endl;
}
} else {
k -= 2;
for (int i = 0, j = n - 1; i < j; ++i) {
while (i < j && a[i] + a[j] >= m * 2) --j;
if (j < n - 1) ++j;
if (a[i] + a[j] != m * 2) continue;
if (i < j && i >= k / 2 && j < n - k / 2) {
cout << "TAK" << endl;
return ;
}
}
cout << "NIE" << endl;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
init();
int t = 1;
cin >> t;
rep (t) {
clear();
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
input:
3 6 4 42 41 43 41 57 41 42 4 2 4 1 2 5 8 7 5 57 101 2 42 5 57 7 13
output:
TAK NIE NIE
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 25ms
memory: 4488kb
input:
1 200000 2 482043846 410684388 380438852 309193412 468460689 586281084 680820569 266819813 639025900 488292166 503516930 532292185 618277661 728546481 628339224 673945619 471325257 372807753 325778059 372151033 548358519 276494019 336701079 320784795 377493322 385262271 621712987 349634764 668994576...
output:
NIE
result:
ok single line: 'NIE'
Test #3:
score: 0
Accepted
time: 20ms
memory: 3704kb
input:
10 20000 3530 502140211 367996343 553577602 581694419 435810361 532394401 431613294 485360190 608191058 506969937 531905607 429252296 360241499 519031654 250454430 478548102 753825992 450326073 603766643 566036856 511634983 416622101 753825992 753825992 380511285 390746506 436237616 342529443 878920...
output:
NIE TAK TAK NIE TAK NIE NIE NIE NIE NIE
result:
ok 10 lines
Test #4:
score: 0
Accepted
time: 19ms
memory: 3660kb
input:
10 20000 6 569116309 533654855 569116308 512534907 569116310 500238175 562175605 569116308 569116310 489499020 543748669 569116309 526641247 511510060 504576222 569116309 569116310 569116308 569116310 569116309 569116308 569116309 569116310 569116308 569116310 569116309 569116308 465300463 569116308...
output:
TAK TAK NIE NIE NIE NIE NIE TAK NIE TAK
result:
ok 10 lines
Test #5:
score: 0
Accepted
time: 20ms
memory: 4336kb
input:
1 200000 99999 519401084 60561374 111262859 724696443 994449169 60561374 44352999 44352999 994449169 333890219 44352999 326562388 994449169 60561374 994449169 111262859 614556033 60561374 994449169 60561374 994449169 44352999 994449169 60561374 335786619 994449169 994449169 629087444 44352999 464308...
output:
TAK
result:
ok single line: 'TAK'
Test #6:
score: -100
Wrong Answer
time: 18ms
memory: 3632kb
input:
10000 20 4 803793916 803793916 803793916 829654242 823538042 845455104 810621895 828304843 832321738 852423770 843342850 807940523 803793916 852745476 848104693 805326240 842124638 854328280 846662656 851682131 821969928 20 6 500022430 627268122 349233632 48722 48722 85853795 617231525 67926484 2957...
output:
NIE NIE NIE NIE NIE TAK NIE NIE NIE NIE NIE TAK TAK NIE TAK NIE TAK NIE NIE NIE TAK NIE TAK NIE TAK NIE NIE NIE NIE TAK TAK TAK TAK TAK TAK NIE NIE TAK NIE NIE NIE TAK NIE NIE NIE TAK NIE NIE NIE NIE TAK NIE TAK NIE TAK NIE TAK TAK NIE TAK NIE NIE NIE TAK TAK NIE TAK TAK NIE NIE NIE TAK TAK TAK NIE ...
result:
wrong answer 1st lines differ - expected: 'TAK', found: 'NIE'