QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#519715 | #8760. 不等式 | Xiao_Shuai_Ge | WA | 4ms | 15644kb | C++14 | 606b | 2024-08-15 00:25:26 | 2024-08-15 00:25:27 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
using namespace std;
unordered_set<int>g[200005];
int a[200005]={0};
int d[200005]={0};
ll res=0;
void dfs(int u) {
if (d[u]) {
res=-1;
return ;
}
if (g[u].empty()) d[u]=1;
else d[u]=0;
for (auto x:g[u]) {
dfs(x);
if (res==-1) return ;
d[u]+=d[x];
}
res+=d[u];
}
int main()
{
int n,m;
cin>>n>>m;
int x,y,z;
while (m--) {
cin>>x>>y>>z;
a[x]+=2;
g[x].insert(y);
g[x].insert(z);
}
for (int i=1;i<=n;i++) {
if (d[i]==0) dfs(i);
if (res==-1) break;
}
cout<<res<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 4ms
memory: 15644kb
input:
3 1 1 2 2
output:
3
result:
wrong answer 1st numbers differ - expected: '4', found: '3'