QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#259791 | #5511. Minor Evil | w4p3r# | RE | 0ms | 3628kb | C++20 | 1.4kb | 2023-11-21 13:51:18 | 2023-11-21 13:51:18 |
Judging History
answer
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define REP(i,a,b) for(int i=a;i>=b;i--)
#define db double
#define ve vector<int>
#define pa pair<int,int>
#define fr first
#define sd second
#define pb push_back
#define mp make_pair
#define MEM(a) memset(a,0,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
inline ll read()
{
char ch = getchar();
ll s = 0, w = 1;
while (ch < '0' || ch > '9') {if (ch == '-')w = -1; ch = getchar();}
while (ch >= '0' && ch <= '9') {s = s * 10 + ch - '0'; ch = getchar();}
return s * w;
}
void sol()
{
int n, m, k;
cin >> n >> m;
vector<int>a(m + 1), b(m + 1), vst(n + 1, 0), has(n + 1, 0), ans(m + 1, 0);
vector<int>s(k + 1);
for (int i = 1; i <= m; i ++)cin >> a[i] >> b[i];
cin >> k;
for (int i = 1; i <= k; i ++) {cin >> s[i]; has[s[i]] = 1;}
for (int i = m; i >= 1; i --)
{
if (has[b[i]] && !vst[b[i]])
{
if (!has[a[i]] || vst[a[i]]) {vst[b[i]] = 1; ans[i] = 1;}
else ans[i] = 0;
}
else ans[i] = 0;
}
for (int i = 1; i <= n; i ++)if (has[i] && !vst[i]) {cout << "NIE\n"; return ;}
cout << "TAK\n";
for (int i = 1; i <= m; i ++)cout << (ans[i] ? 'T' : 'N'); cout << '\n';
}
signed main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T; cin >> T;
while (T --)sol();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
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
Runtime Error
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...