QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#267833 | #5511. Minor Evil | kilo_tobo_tarjen# | WA | 775ms | 6724kb | C++20 | 1.6kb | 2023-11-27 19:14:18 | 2023-11-27 19:14:19 |
Judging History
answer
#include <bits/stdc++.h>
// #include <bits/extc++.h>
// using namespace __gnu_cxx;
// using namespace __gnu_pbds;
using i64 = long long;
using namespace std;
const int N = 1e6 + 5;
// const int B = 500;
// const int M = 50005;
// const int base = 17131;
const int mod = 998244353;
// const int mod = 1e9 + 7;
// const double pi = acos(-1);
/*
1
3 4
3 1
3 2
2 1
1 2
2
1 2
*/
int n, k, a[N], b[N];
void solve()
{
cin >> n >> k;
for (int i = 1; i <= k; i++)
cin >> a[i] >> b[i];
int s;
cin >> s;
set<int> vis, killed, protect;
for (int i = 1, x; i <= s; i++)
cin >> x, vis.insert(x);
vector<int> tmp;
for (int i = k; i >= 1; i--)
{
if (vis.count(b[i]) && !vis.count(a[i]))
{
tmp.push_back(i);
vis.erase(b[i]);
protect.insert(a[i]);
}
}
reverse(tmp.begin(), tmp.end());
if (tmp.size() != s)
{
cout << "NIE\n";
return;
}
string ans;
for (int i = 1, j = 0; i <= k; i++)
{
if (tmp[j] == i)
{
if (killed.count(a[i]))
{
cout << "NIE\n";
return;
}
killed.insert(b[i]);
ans.push_back('T');
j++;
}
else
ans.push_back('N');
}
cout << "TAK\n";
cout << ans << '\n';
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
cout << fixed << setprecision(12);
while (t--)
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5580kb
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: -100
Wrong Answer
time: 775ms
memory: 6724kb
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:
wrong answer Contestant didn't find the solution. (test case 991)