QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#77677#5511. Minor EvilXKErrorWA 694ms40696kbC++1.5kb2023-02-15 12:32:402023-02-15 12:32:41

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-15 12:32:41]
  • 评测
  • 测评结果:WA
  • 用时:694ms
  • 内存:40696kb
  • [2023-02-15 12:32:40]
  • 提交

answer

#include <bits/stdc++.h>

#define maxn 1000005

using namespace std;

int n, k;
int a[maxn];
int b[maxn];

int m;
int s[maxn];

vector<pair<int, int> > g[maxn];

void add(int u, int v, int w) {
//	cout<<"ADd:"<<u<<" "<<v<<" "<<w<<endl;
	g[u].push_back({v, w});
//	g[v].push_back({u, w});
}

int f[maxn];
int res[maxn];

queue<int> q;

int main() {
	int T;
	scanf("%d", &T);
	while (T--) {
		scanf("%d%d", &n, &k);
		for (int i = 1; i <= n; i++) f[i] = k + 1;
		for (int i = 1; i <= k; i++) scanf("%d%d", &a[i], &b[i]);
		scanf("%d", &m);
		for (int i = 1; i <= m; i++) {
			int x;
			scanf("%d", &x);
			s[x] = 1;
		}
		for (int i = 1; i <= k; i++) {
			if (s[b[i]]) add(a[i], b[i], i);
		}
		for (int i = 1; i <= n; i++) if (!s[i]) q.push(i);
		while (!q.empty()) {
			int now = q.front(); q.pop();
			for (auto p : g[now]) {
				int v = p.first, w = p.second;
//				cout<<now<<" "<<f[now]<<" "<<w<<" "<<f[v]<<endl;
				if (f[now] > w && (f[v] < w || f[v] == k + 1)) {
					f[v] = w;
					q.push(v);
				}
			}
		}
		bool flg = 1;
		for (int i = 1; i <= n; i++) {
			if (s[i]) {
//				cout<<f[i]<<"@"<<endl;
				if (f[i] <= k) res[f[i]] = 1;
				else flg = 0;
			}
		}
		if (!flg) {
			puts("NIE");
			for (int i = 1; i <= n; i++) res[i] = f[i] = s[i] = 0, g[i].clear();
			continue;
		}
		puts("TAK");
		for (int i = 1; i <= k; i++) putchar(res[i] ? 'T' : 'N');
		puts("");
		for (int i = 1; i <= n; i++) res[i] = f[i] = s[i] = 0, g[i].clear();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 27016kb

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: 694ms
memory: 40696kb

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
NNTT
NIE
TAK
NNTT
NIE
NIE
TAK
NNNT
NIE
TAK
NNTT
NIE
NIE
NIE
NIE
NIE
NIE
NIE
NIE
TAK
NNT
NI...

result:

wrong answer Some poeple who should be dead are alive. (test case 70)