Submission #581720

# Submission time Handle Problem Language Result Execution time Memory
581720 2022-06-23T04:48:54 Z 반딧불(#8365) 전압 (JOI14_voltage) C++14
0 / 100
1000 ms 14900 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, m;
vector<int> link[100002];
int ex[100002], ey[100002];
int ans;
ll S, M;

bool visited[100002];
bool col[100002];
bool dfs(int x, int p=-1){
    visited[x] = 1;
    for(auto y: link[x]){
        int nc = !col[x];
        if(y+x==S && ll(y)*x==M) nc=!nc;
        if(visited[y]){
            if(col[y]!=nc) return false;
            continue;
        }
        col[y] = nc;
        if(!dfs(y, x)) return false;
    }
    return true;
}

int main(){
    scanf("%d %d", &n, &m);
    for(int i=1; i<=m; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        link[x].push_back(y);
        link[y].push_back(x);
        ex[i] = x, ey[i] = y;
    }
    for(int i=1; i<=m; i++){
        S = ex[i]+ey[i];
        M = ll(ex[i])*ll(ey[i]);
        memset(visited, 0, sizeof(visited));
        if(dfs(1)) ans++;
    }
    printf("%d", ans);
}

Compilation message

voltage.cpp: In function 'int main()':
voltage.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
voltage.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         scanf("%d %d", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 2772 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 8236 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 7904 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 33 ms 14900 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -