QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#111675 | #5511. Minor Evil | xaphoenix# | AC ✓ | 793ms | 24700kb | C++14 | 1.8kb | 2023-06-07 21:06:51 | 2023-06-07 21:06:55 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define LC k<<1
#define RC k<<1|1
#define IO cin.sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define rep(i,a,n) for (int i = a; i < n; i++)
#define repn(i,a,n) for (int i = a; i <= n; i++)
#define per(i,a,n) for (int i = (n) - 1; i >= a; i--)
#define pern(i,a,n) for (int i = n; i >= a; i--)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<int, LL> PIL;
typedef pair<LL, int> PLI;
typedef pair<double, double> PDD;
typedef pair<ull, ull> PUU;
typedef pair<LL, LL> PLL;
const int N = 1100000;
const int M = 1100000;
const int mod = 1e9+7;
const int inf = (int)1e9;
const LL INF = 1e18;
const double eps = 1e-9;
mt19937_64 Rand((unsigned long long)new char);
#define rand Rand
int T, n, k, m, pp[N], ans[N], cp[N], a[N], b[N];
int main() {
IO;
cin >> T;
while (T--) {
cin >> n >> k;
repn(i, 1, n) pp[i] = cp[i] = 0;
repn(i, 1, k) cin >> a[i] >> b[i];
cin >> m;
pern(i, 1, m) {
int x;
cin >> x;
cp[x] = 1;
}
pern(i, 1, k) {
if (!cp[b[i]]) {
ans[i] = 0;
continue;
}
if (!cp[a[i]]) {
if (!pp[b[i]]) pp[b[i]] = 1, ans[i] = 1;
else ans[i] = 0;
continue;
}
if (!pp[a[i]]) ans[i] = 0;
else {
if (!pp[b[i]]) pp[b[i]] = 1, ans[i] = 1;
else ans[i] = 0;
}
}
int flag = 0;
repn(i, 1, n) if (cp[i] && !pp[i]) flag = 1;
if (flag) cout << "NIE\n";
else {
cout << "TAK\n";
repn(i, 1, k) if (ans[i]) cout << "T"; else cout << "N";
cout << "\n";
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 4ms
memory: 11632kb
input:
2 5 6 1 2 2 1 2 5 2 3 2 4 4 2 3 1 2 3 3 2 1 2 2 3 2 2 3
output:
TAK NTNTNT NIE
result:
ok correct (2 test cases)
Test #2:
score: 0
Accepted
time: 560ms
memory: 11688kb
input:
1000 5 6 1 2 2 1 2 5 2 3 2 4 4 2 3 1 2 3 3 2 1 2 2 3 2 2 3 2 1 1 2 1 1 2 1 1 2 1 2 3 3 2 1 3 2 3 2 1 3 3 3 1 3 1 3 1 2 2 1 3 3 3 1 2 1 3 1 3 1 2 3 3 2 1 2 3 1 3 1 2 3 3 3 2 3 1 1 2 3 1 2 3 3 3 1 2 2 3 1 2 1 3 3 3 2 1 1 2 1 2 1 2 3 3 2 1 1 3 1 3 1 1 3 3 3 2 3 2 2 3 1 3 3 3 3 2 1 2 2 1 1 1 3 3 2 1 3 2...
output:
TAK NTNTNT NIE NIE TAK T NIE NIE TAK TNN NIE NIE TAK NTN TAK NNT TAK TNN TAK NNT TAK NNT TAK NNT NIE NIE NIE NIE NIE NIE NIE NIE NIE TAK NTNN TAK TNTN NIE NIE NIE NIE NIE NIE NIE TAK TNTN TAK NNTN TAK NNNT TAK NNTN NIE TAK NNTN NIE NIE TAK NNNT NIE TAK NNTN NIE NIE NIE NIE NIE NIE NIE NIE TAK NNT NI...
result:
ok correct (1000 test cases)
Test #3:
score: 0
Accepted
time: 733ms
memory: 24700kb
input:
13 1000000 1000000 486802 809159 104883 440551 501905 622668 279504 663293 839882 889531 125252 955226 270422 92128 363725 456993 513782 686348 292006 59538 112416 619373 150140 212648 891080 338487 348780 833779 186126 366730 294350 778236 173878 385135 831186 985800 868035 100117 752578 739541 457...
output:
NIE NIE NIE TAK NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...
result:
ok correct (13 test cases)
Test #4:
score: 0
Accepted
time: 620ms
memory: 24648kb
input:
4 1000000 1000000 883198 803418 803418 883198 883198 803418 803418 883198 883198 803418 803418 883198 803418 883198 883198 803418 883198 803418 883198 803418 883198 803418 883198 803418 803418 883198 883198 803418 803418 883198 803418 883198 883198 803418 883198 803418 883198 803418 803418 883198 88...
output:
NIE NIE NIE NIE
result:
ok correct (4 test cases)
Test #5:
score: 0
Accepted
time: 793ms
memory: 24492kb
input:
4 1000000 1000000 820179 264070 64152 264070 264070 865675 614523 264070 264070 701152 609404 264070 793293 264070 264070 809556 467741 643260 337227 264070 264070 445071 248826 822649 856028 128336 367537 264070 81341 264070 476352 687682 306818 264070 123295 410991 255671 264070 61947 264070 24372...
output:
TAK NNNNTNNNNNTNNNNNNNNNNNTNTNNTNNNTNNTNNNTNTTTNNNNNTNNNNNNTNTTNNNTNNNTTTNTNNNNNTNNNNNTNTTNNTNNNTTTTNTNNNTNNTTTTNNTNTNNNNTTNTNTTTTNNNNNNNTNTNNNNTNNNNTTTNNNNNNTNTNNNNNTTNTTNNTNNNNTNTNTNNTTTNNTNNTNTNNTTNTNNNNNNNTNNNNTTNNNNNNNNNTNNTNNNTTNNTTNNTNNTNNNNTNNNTNTNNTTNNNNNTNNNNNNNTNTNNNTNTNNNNNNNTNNNNNTNTNNT...
result:
ok correct (4 test cases)
Test #6:
score: 0
Accepted
time: 776ms
memory: 24468kb
input:
4 1000000 1000000 744622 299781 744622 837726 883242 744622 672533 744622 744622 685446 942503 744622 677083 744622 744622 624546 744622 586007 193995 744622 744622 276667 744622 733596 744622 458621 744622 685762 232706 744622 744622 460264 744622 683335 744622 708865 744622 893299 744622 254173 31...
output:
TAK TTNNTNNTTNTTTTNTTTTTNTTTTTNTTTNTNTTTTNTTTTTTTTTNNTTTTNTNNTTTTTTTTTTTNTTTTTTTTTTTNTNTTTNTTTTTTTTTTTTTTNNTNTNTTNTTTTTTNTTTTNTNTTNTTTTTTTTTTTTTNTTTTTTTNTTTTTTNTTNTTTNTTTTTTTTTNNTTTTTTTNTTTNTTTTTTTTNNNNTTTTTTTTTTTTTNNTTTTTTTTTNTTTNNTTNNTTTTTTTTTTTTTNTTTTTTTTTNTTTTTNTTTTTTTNNTTTTTTTTTTTTTNTTTTTTTNTNT...
result:
ok correct (4 test cases)