QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#641530#905. 三元环枚举Zhou_JKWA 1ms3660kbC++23878b2024-10-14 20:57:322024-10-14 20:57:32

Judging History

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

  • [2024-10-14 20:57:32]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3660kb
  • [2024-10-14 20:57:32]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
constexpr int N=100005,M=100005;
int n,m;
int u[M],v[M];
int deg[N];
vector<int>G[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    cin>>n>>m;
    fill(deg+1,deg+n+1,0); 
    for(int i=1;i<=m;i++)
    {
        cin>>u[i]>>v[i];
        deg[u[i]]++,deg[v[i]]++;
    }
    for(int i=1;i<=m;i++)
    {
        if(deg[u[i]]>deg[v[i]]||(deg[u[i]]==deg[v[i]]&&u[i]>v[i])) swap(u[i],v[i]);
        G[u[i]].emplace_back(v[i]);
    }
    int ans=0;
    for(int u=1;u<=n;u++)
    {
        static bool vis[N];
        for(int v:G[u])
            vis[v]=true;
        for(int v:G[u])
            for(int w:G[v])
                if(vis[w]) ans++;
        for(int v:G[u])
            vis[v]=false;
    }
    cout<<ans;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3660kb

input:

4 5
1 2 3 4
0 3
2 0
2 1
2 3
1 3

output:

0

result:

wrong answer 1st words differ - expected: '36', found: '0'