QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#259791#5511. Minor Evilw4p3r#RE 0ms3628kbC++201.4kb2023-11-21 13:51:182023-11-21 13:51:18

Judging History

你现在查看的是最新测评结果

  • [2023-11-21 13:51:18]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3628kb
  • [2023-11-21 13:51:18]
  • 提交

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...

output:


result: