QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#229750#7640. Colorful Cyclesucup-team2303#WA 176ms79464kbC++141.7kb2023-10-28 16:48:462023-10-28 16:48:47

Judging History

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

  • [2024-07-04 22:58:32]
  • hack成功,自动添加数据
  • (/hack/728)
  • [2023-10-28 16:48:47]
  • 评测
  • 测评结果:WA
  • 用时:176ms
  • 内存:79464kb
  • [2023-10-28 16:48:46]
  • 提交

answer

// #pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;

#define PB emplace_back
// #define int long long
#define ll long long
#define vi vector<int>
#define siz(a) ((int) ((a).size()))
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
void print(vi n) {rep(i, 0, siz(n) - 1) cerr << n[i] << " \n"[i == siz(n) - 1];}

const int N = 1e6;
int T, a, b, in[N + 5], vis[N + 5];
vi st[3][N + 5];
struct pii {int x, y, z;} s[N + 5];

bool find(int n) {
	rep(i, 0, 2) for(int x : st[i][n]) vis[x] = i;
	bool res = 0;
	rep(i, 0, 2) for(int x : st[i][n]) {
		rep(j, 0, 2) if(i != j) for(int y : st[j][x]) if(vis[y] != j && vis[y] != i) res = 1;
		if(res) break;
	}
	rep(i, 0, 2) for(int x : st[i][n]) vis[x] = -1;
	return res;
}

signed main() {
	// freopen(".in", "r", stdin);
	// freopen(".out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	memset(vis, -1, sizeof(vis));
	for(cin >> T; T--; ) {
		cin >> a >> b;
		rep(i, 1, a) st[0][i].clear(), st[1][i].clear(), st[2][i].clear(), in[i] = 0;
		int x, y, z;
		rep(i, 1, b) {
			cin >> x >> y >> z;
			s[i] = pii {x, y, z};
			++in[x], ++in[y];
		}
		rep(i, 1, b) {
			auto [x, y, z] = s[i];
			if(in[x] > in[y] || (in[x] == in[y] && x < y)) st[z - 1][x].PB(y);
			else st[z - 1][y].PB(x);
		}
		bool ans = 0;
		rep(i, 1, a) if(find(i)) {
			ans = 1;
			break;
		}
		ans ? cout << "Yes\n" : cout << "No\n";
	}
	return cerr << endl << 1.0 * clock() / CLOCKS_PER_SEC << endl, 0;
}

详细

Test #1:

score: 100
Accepted
time: 10ms
memory: 79464kb

input:

2
3 3
1 2 3
2 3 1
1 3 2
5 6
1 2 1
2 3 1
1 3 2
3 4 3
3 5 3
4 5 3

output:

Yes
No

result:

ok 2 token(s): yes count is 1, no count is 1

Test #2:

score: -100
Wrong Answer
time: 176ms
memory: 79044kb

input:

100000
7 10
7 2 2
6 4 2
6 1 2
7 1 3
3 4 1
6 7 1
2 6 3
3 1 2
5 3 1
2 1 1
7 10
5 7 3
7 1 1
4 6 3
6 3 1
3 4 3
4 2 2
3 2 3
1 3 3
3 7 1
1 4 2
7 10
5 6 3
3 5 2
7 2 3
7 3 3
1 2 2
4 3 2
7 4 2
6 1 2
2 6 1
7 5 2
7 10
7 1 3
7 5 3
6 4 1
7 6 1
1 4 1
3 4 2
2 7 2
1 3 1
3 5 3
5 1 3
7 10
6 7 2
3 4 3
1 4 2
5 3 2
7 4 ...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Y...

result:

wrong answer expected NO, found YES [13th token]