Submission #262387

# Submission time Handle Problem Language Result Execution time Memory
262387 2020-08-12T19:07:41 Z CaroLinda Duathlon (APIO18_duathlon) C++14
0 / 100
1 ms 512 KB
#include <bits/stdc++.h>

#define lp(i,a,b) for(int i = a; i < b ; i++)
#define ff first
#define ss second
#define pb emplace_back
#define ll long long
#define mk make_pair
#define sz(x) x.size()
#define pii pair<int,int>
#define mkt make_tuple
#define debug printf

const int MAXN = 55 ;
const int MAXM = 410 ;
const int inf = 1e9+7;

using namespace std ;

int N , M , resp , T ;
int flow[MAXM] , cap[MAXM] , pai[MAXN*2] ;
vector<int> pilha ;
vector<pii> adj[MAXN*2] ;
bool vis[MAXN] ;
bool flag ;

int get(int x) { return cap[x] - flow[x] ; }

int bfs(int x )
{
    vis[x] = true ;

    if(x == T) return inf ;

    for(auto e : adj[x] )
    {

        if( get(e.ss) <= 0 || vis[e.ff] ) continue ;

        int t = min(bfs(e.ff), get(e.ss) ) ;

        if(t <= 0) continue ;

        pilha.pb( e.ss ) ;
        return t ;

    }

    return 0 ;

}

int op(int x) { return (x > M) ? (x-M) : (x+M) ; }

int test(int a, int b, int c )
{
    lp(i,1,M+1) cap[i] = 1 , flow[i] = flow[i+M] = 0 ;

    T = 2*N+1 ;

    adj[b+N].pb( mk( T , M-1 ) ) ;
    adj[b+N].pb( mk( T , M-1+M ) ) ;
    adj[c+N].pb( mk(T,M) ) ;
    adj[c+N].pb( mk(T,M+M) ) ;
    cap[ adj[a][0].ss ]++ ;

    int F = 0  , f = 0 ;

    lp(i,1,T+1) vis[i] = false ;
    pilha.clear() ;

    while( f = bfs(a) )
    {
        F += f ;

        lp(i,1,T+1) vis[i] = false ;

        for(auto e : pilha )
        {
            flow[e] += f ;
            flow[ op(e) ] -= f ;
        }

        pilha.clear() ;

    }

    adj[b+N].pop_back() ;
    adj[b+N].pop_back() ;
    adj[c+N].pop_back() ;
    adj[c+N].pop_back() ;
    cap[ adj[a][0].ss ]-- ;


    return F >= 2 ;

}

int main()
{

    scanf("%d%d", &N , &M ) ;

    lp(i,1,N+1) adj[i].pb( mk(i+N , M+i) ) ;

    for(int i = 1 , u , v ; i <= M ; i++ )
    {
        scanf("%d%d", &u, &v ) ;
        adj[u+N].pb( mk(v,i) ) ;
        adj[v+N].pb( mk(u,i) ) ;
    }
    M += N+2 ;

    lp(i,1,N+1)
        for(auto e : adj[i] ) adj[i].pb( mk(e.ff, e.ss+M) ) ;

    for(int i = 1 ; i <= N ; i++ )
        for(int j = 1 ; j <= N ; j++ )
            for(int g = j+1 ; g <= N ; g++ )
                if( i != j && i != g ) resp += 2*test(i,j,g) ;

    printf("%d\n" , resp ) ;

}

Compilation message

count_triplets.cpp: In function 'int test(int, int, int)':
count_triplets.cpp:72:14: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   72 |     while( f = bfs(a) )
      |            ~~^~~~~~~~
count_triplets.cpp: In function 'int main()':
count_triplets.cpp:102:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  102 |     scanf("%d%d", &N , &M ) ;
      |     ~~~~~^~~~~~~~~~~~~~~~~~
count_triplets.cpp:108:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  108 |         scanf("%d%d", &u, &v ) ;
      |         ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -