Submission #430310

# Submission time Handle Problem Language Result Execution time Memory
430310 2021-06-16T12:51:21 Z Ruba_K Duathlon (APIO18_duathlon) C++14
0 / 100
1000 ms 13116 KB
#include<bits/stdc++.h>
/*
Created By Tornado2004
*/
using namespace std;

#define debug(x) cout << '[' << #x << " is: " << x << "] " << endl;
#define imod(a , n) (a % n + n ) % n

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define inF freopen("wormsort.in","r",stdin );
#define outF freopen("wormsort.out" , "w" , stdout ) ;
#define sor(v) sort(v.begin() , v.end());
#define print(v) for(auto f : v ) cout << f << " " ;
#define rsor(v) sort(v.rbegin() , v.rend());
#define rev(v) reverse(v.begin() , v.end());
#define scan(v)for(auto &it : v)cin >> it ;

#define ll long long
//#define int ll
#define logar(x , y) log(x) / log(y)
#define __sum(n) n * (n + 1) / 2
#define __lcm(a , b) a / __gcd(a , b) * b
#define pii pair<int , int >
const int N = 2e5 + 3 , K = 11 , M = N * 4 ;
const ll MOD = 998244353 , oo = 1e9 , OO = 1e18 , mod = MOD ;
const double pi = acos(-1) , eps = 1e-17 ;

//37
// (a ^ b / c ) % mod = (a ^ b ) % MOD * (c ^ (mod - 2)) % mod
// m is prime --> (a ^ m) % m = a % m


vector<int> adj[N];

int vis[N] , vid ;
ll ans ;

int a , b , c ;
int aa = 0 ;
int timer ;

void dfs(int u){
    if(timer > 1e4)return ;

    if(u == c){
        if(vis[b] == vid) aa = 1 ;

        return ;


    }
    for(auto f : adj[u]){
if(timer > 1e4)return ;
        if(vis[f] != vid){
            vis[f] = vid ;
if(timer > 1e4)return ;
            dfs(f);
if(timer > 1e4)return ;
            vis[f] = 0 ;


        }

    }



}

int32_t main()
{   //inF;
   //inF;outF;
    fastio;

    int n , m ;
    cin >> n >> m ;

    for(int i = 0 ; i < m ; i ++){
        int a , b;
        cin >>a >> b;
//        mat[a][b] = mat[b][a] = 1 ;


        adj[a].push_back(b);
        adj[b].push_back(a);

    }


    if(n < 3)cout << 0 ;
    else {



        for(int i = 1 ; i <= n ; i ++){
            for(int j = 1 ; j <= n ; j ++){

                for(int cc = 1 ; cc <= n; cc ++){

                    a = i , b = j , c = cc ;
                    if(a == b || a == c || b == c)continue ;
                    vid ++ ;
                    vis[a] = vid ;
                    aa = 0 ;
                    timer = 0 ;

                    dfs(a);
                    ans += aa ;
                   // if(aa)cout << a << " " << b << " " << c << endl;

                }
            }

        }

        cout << ans ;

    }

}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5068 KB Output is correct
2 Correct 4 ms 4940 KB Output is correct
3 Correct 4 ms 4940 KB Output is correct
4 Correct 5 ms 4940 KB Output is correct
5 Correct 5 ms 4940 KB Output is correct
6 Correct 4 ms 4940 KB Output is correct
7 Correct 4 ms 4940 KB Output is correct
8 Correct 9 ms 4940 KB Output is correct
9 Correct 156 ms 4988 KB Output is correct
10 Execution timed out 1085 ms 4940 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5068 KB Output is correct
2 Correct 4 ms 4940 KB Output is correct
3 Correct 4 ms 4940 KB Output is correct
4 Correct 5 ms 4940 KB Output is correct
5 Correct 5 ms 4940 KB Output is correct
6 Correct 4 ms 4940 KB Output is correct
7 Correct 4 ms 4940 KB Output is correct
8 Correct 9 ms 4940 KB Output is correct
9 Correct 156 ms 4988 KB Output is correct
10 Execution timed out 1085 ms 4940 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 13116 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 4940 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1069 ms 8516 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 4940 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 8516 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5068 KB Output is correct
2 Correct 4 ms 4940 KB Output is correct
3 Correct 4 ms 4940 KB Output is correct
4 Correct 5 ms 4940 KB Output is correct
5 Correct 5 ms 4940 KB Output is correct
6 Correct 4 ms 4940 KB Output is correct
7 Correct 4 ms 4940 KB Output is correct
8 Correct 9 ms 4940 KB Output is correct
9 Correct 156 ms 4988 KB Output is correct
10 Execution timed out 1085 ms 4940 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5068 KB Output is correct
2 Correct 4 ms 4940 KB Output is correct
3 Correct 4 ms 4940 KB Output is correct
4 Correct 5 ms 4940 KB Output is correct
5 Correct 5 ms 4940 KB Output is correct
6 Correct 4 ms 4940 KB Output is correct
7 Correct 4 ms 4940 KB Output is correct
8 Correct 9 ms 4940 KB Output is correct
9 Correct 156 ms 4988 KB Output is correct
10 Execution timed out 1085 ms 4940 KB Time limit exceeded
11 Halted 0 ms 0 KB -