QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#463452 | #7640. Colorful Cycles | CelestialCoder | WA | 111ms | 5700kb | C++20 | 1.9kb | 2024-07-04 21:04:48 | 2024-07-04 21:04:49 |
Judging History
answer
#include <bits/stdc++.h>
#ifdef SHARAELONG
#include "../../cpp-header/debug.hpp"
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAX_N = 5e5 + 1;
vector<pii> adj[MAX_N];
int bcc[MAX_N];
vector<int> st;
int low[MAX_N], dfn[MAX_N];
int piv = 0, c = 0;
void dfs(int x, int p){
if (adj[x].empty()) {
bcc[x] = ++c;
return;
}
dfn[x] = low[x] = ++piv;
st.push_back(x);
for (auto[v, _]: adj[x]) {
if (!dfn[v]) {
dfs(v, x);
low[x] = min(low[x], low[v]);
} else if (v != p) {
low[x] = min(low[x], dfn[v]);
}
}
if (low[x] == dfn[x]) {
c++;
int e;
do {
e = st.back();
st.pop_back();
bcc[e] = c;
} while (e != x);
}
}
void solve() {
int n, m;
cin >> n >> m;
st.clear();
for (int i=0; i<=n; ++i) {
adj[i].clear();
bcc[i] = low[i] = dfn[i] = 0;
}
piv = 0; c = 0;
for (int i=0; i<m; ++i) {
int a, b, c;
cin >> a >> b >> c;
adj[a].push_back({ b, c });
adj[b].push_back({ a, c });
}
dfs(1, -1);
vector<pii> ok(c+1);
for (int i=1; i<=n; ++i) {
int b = bcc[i];
int tmp = 0;
for (auto[j, k]: adj[i]) {
if (bcc[j] == b) {
ok[b].first |= (1 << k);
tmp |= (1 << k);
}
}
if (__builtin_popcount(tmp) >= 2) ok[b].second++;
}
for (int i=1; i<=c; ++i) {
if (ok[i].first / 2 == 7 && ok[i].second >= 3) {
cout << "Yes\n";
return;
}
}
cout << "No\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int cases;
cin >> cases;
while (cases--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 5660kb
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: 111ms
memory: 5700kb
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 No Yes Yes Yes Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes Yes No 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 ...
result:
wrong answer expected NO, found YES [131st token]