QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#474506 | #5511. Minor Evil | piratZnachor# | WA | 373ms | 3828kb | C++14 | 1.9kb | 2024-07-12 19:23:28 | 2024-07-12 19:23:29 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
template<typename _T> void _debug(const char *s, _T x){ cerr << s << " = " << x << "\n";}
template<typename _T, typename... R> void _debug(const char *s, _T x, R... r){ while(*s != ',') cerr << *s++; cerr << " = " << x << ", "; _debug(s + 1, r...);}
#define debug(...) _debug(#__VA_ARGS__, __VA_ARGS__)
#define sz(s) int32_t(s.size())
#define all(x) begin(x), end(x)
#define getuniqe(x) x.erase(unique(all(x)), end(x))
#define X first
#define Y second
using ll = long long;
using ld = long double;
#define int ll
const int N = 1e6 + 5;
bool to_kill[N], will_be_killed[N], is_killed[N];
void solve() {
int n, k; cin >> n >> k;
vector<int> a(k), b(k);
for (int i = 0; i < k; i++) {
cin >> a[i] >> b[i];
}
int s; cin >> s;
vector<int> vec(s);
for (int i = 0; i < s; i++) {
cin >> vec[i];
to_kill[vec[i]] = true;
}
string res;
for (int i = k - 1; i >= 0; i--) {
if ((to_kill[a[i]] && to_kill[b[i]]) || (!to_kill[a[i]] && to_kill[b[i]])) {
if (will_be_killed[b[i]]) res += 'N';
else {
will_be_killed[b[i]] = true;
res += 'T';
}
} else res += 'N';
}
reverse(all(res));
for (int i = 0; i < k; i++) {
if (res[i] == 'N') continue;
else if (is_killed[a[i]] || is_killed[b[i]]) continue;
else is_killed[b[i]] = true;
}
bool ok = true;
for (int x: vec) ok &= is_killed[x];
if (ok) cout << "TAK\n" << res << "\n";
else cout << "NIE\n";
for (int x: vec) is_killed[x] = to_kill[x] = will_be_killed[x] = false;
}
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int tests = 1; cin >> tests;
for (int test_case = 1; test_case <= tests; test_case++) {
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3816kb
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: 373ms
memory: 3828kb
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 68)