답안 #262396

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
262396 2020-08-12T20:11:31 Z CaroLinda 철인 이종 경기 (APIO18_duathlon) C++14
16 / 100
253 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

const int MAXN = 110 ;
const int MAXM = 510;
const int inf = 1e9+7;

using namespace std ;

int N , M , resp , T , MM ;
int flow[MAXM] , cap[MAXM] , cont[MAXM] ;
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 ;

        //cout << x << " " << get(e.ss) << " " << e.ss << " " << e.ff << endl ;

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

        if(t <= 0) continue ;

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

    }

    return 0 ;

}

void add_edge(int x, int y , int c)
{
    cap[++M] = c ;
    flow[M] = 0 ;
    adj[x].pb( mk(y,M) ) ;
    cont[M] = M+1 ;
    M++ ;
    cont[M] = M-1 ;
    flow[M] = 0 ;
    adj[y].pb( mk(x, M) ) ;
}

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

    T = 2*N+1 ;

    add_edge(b+N, T, 1) ;
    add_edge(c+N , T , 1  );
    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[ cont[e] ] -= f ;
        }

        pilha.clear() ;

    }

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


    return F >= 2 ;

}

int main()
{

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

    lp(i,1,N+1) add_edge(i, i+N, 1) ;

    for(int i = 1 , u , v ; i <= MM ; i++ )
    {
        scanf("%d%d", &u, &v ) ;
        add_edge(u+N, v, 1 ) ;
        add_edge( v+N , u , 1 ) ;
    }



    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 )
                    if( test(i,j,g) )
                    {
                        resp += 2 ;
                        debug("Deu bom em %d %d %d\n" , i, j , g ) ;
                    }

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

}

Compilation message

count_triplets.cpp: In function 'int test(int, int, int)':
count_triplets.cpp:83:14: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   83 |     while( f = bfs(a) )
      |            ~~^~~~~~~~
count_triplets.cpp: In function 'int main()':
count_triplets.cpp:134:31: warning: left operand of comma operator has no effect [-Wunused-value]
  134 |                         debug("Deu bom em %d %d %d\n" , i, j , g ) ;
      |                               ^~~~~~~~~~~~~~~~~~~~~~~
count_triplets.cpp:134:60: warning: right operand of comma operator has no effect [-Wunused-value]
  134 |                         debug("Deu bom em %d %d %d\n" , i, j , g ) ;
      |                                                            ^
count_triplets.cpp:134:64: warning: right operand of comma operator has no effect [-Wunused-value]
  134 |                         debug("Deu bom em %d %d %d\n" , i, j , g ) ;
      |                                                                ^
count_triplets.cpp:114:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  114 |     scanf("%d%d", &N , &MM ) ;
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
count_triplets.cpp:120:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  120 |         scanf("%d%d", &u, &v ) ;
      |         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 380 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 376 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 376 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 1 ms 376 KB Output is correct
28 Correct 1 ms 368 KB Output is correct
29 Correct 1 ms 376 KB Output is correct
30 Correct 1 ms 376 KB Output is correct
31 Correct 1 ms 376 KB Output is correct
32 Correct 1 ms 376 KB Output is correct
33 Correct 1 ms 368 KB Output is correct
34 Correct 1 ms 376 KB Output is correct
35 Correct 1 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 380 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 376 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 376 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 1 ms 376 KB Output is correct
28 Correct 1 ms 368 KB Output is correct
29 Correct 1 ms 376 KB Output is correct
30 Correct 1 ms 376 KB Output is correct
31 Correct 1 ms 376 KB Output is correct
32 Correct 1 ms 376 KB Output is correct
33 Correct 1 ms 368 KB Output is correct
34 Correct 1 ms 376 KB Output is correct
35 Correct 1 ms 376 KB Output is correct
36 Correct 13 ms 416 KB Output is correct
37 Correct 19 ms 368 KB Output is correct
38 Correct 115 ms 376 KB Output is correct
39 Correct 180 ms 504 KB Output is correct
40 Correct 253 ms 504 KB Output is correct
41 Correct 15 ms 384 KB Output is correct
42 Correct 17 ms 384 KB Output is correct
43 Correct 18 ms 384 KB Output is correct
44 Correct 20 ms 384 KB Output is correct
45 Correct 20 ms 376 KB Output is correct
46 Correct 23 ms 504 KB Output is correct
47 Correct 1 ms 384 KB Output is correct
48 Correct 16 ms 384 KB Output is correct
49 Correct 15 ms 384 KB Output is correct
50 Correct 13 ms 384 KB Output is correct
51 Correct 81 ms 384 KB Output is correct
52 Correct 98 ms 384 KB Output is correct
53 Correct 127 ms 504 KB Output is correct
54 Correct 138 ms 504 KB Output is correct
55 Correct 144 ms 512 KB Output is correct
56 Correct 156 ms 380 KB Output is correct
57 Correct 115 ms 512 KB Output is correct
58 Correct 111 ms 376 KB Output is correct
59 Correct 83 ms 384 KB Output is correct
60 Correct 71 ms 384 KB Output is correct
61 Correct 46 ms 504 KB Output is correct
62 Correct 28 ms 384 KB Output is correct
63 Correct 74 ms 384 KB Output is correct
64 Correct 81 ms 384 KB Output is correct
65 Correct 83 ms 380 KB Output is correct
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 380 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 376 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 376 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 1 ms 376 KB Output is correct
28 Correct 1 ms 368 KB Output is correct
29 Correct 1 ms 376 KB Output is correct
30 Correct 1 ms 376 KB Output is correct
31 Correct 1 ms 376 KB Output is correct
32 Correct 1 ms 376 KB Output is correct
33 Correct 1 ms 368 KB Output is correct
34 Correct 1 ms 376 KB Output is correct
35 Correct 1 ms 376 KB Output is correct
36 Correct 13 ms 416 KB Output is correct
37 Correct 19 ms 368 KB Output is correct
38 Correct 115 ms 376 KB Output is correct
39 Correct 180 ms 504 KB Output is correct
40 Correct 253 ms 504 KB Output is correct
41 Correct 15 ms 384 KB Output is correct
42 Correct 17 ms 384 KB Output is correct
43 Correct 18 ms 384 KB Output is correct
44 Correct 20 ms 384 KB Output is correct
45 Correct 20 ms 376 KB Output is correct
46 Correct 23 ms 504 KB Output is correct
47 Correct 1 ms 384 KB Output is correct
48 Correct 16 ms 384 KB Output is correct
49 Correct 15 ms 384 KB Output is correct
50 Correct 13 ms 384 KB Output is correct
51 Correct 81 ms 384 KB Output is correct
52 Correct 98 ms 384 KB Output is correct
53 Correct 127 ms 504 KB Output is correct
54 Correct 138 ms 504 KB Output is correct
55 Correct 144 ms 512 KB Output is correct
56 Correct 156 ms 380 KB Output is correct
57 Correct 115 ms 512 KB Output is correct
58 Correct 111 ms 376 KB Output is correct
59 Correct 83 ms 384 KB Output is correct
60 Correct 71 ms 384 KB Output is correct
61 Correct 46 ms 504 KB Output is correct
62 Correct 28 ms 384 KB Output is correct
63 Correct 74 ms 384 KB Output is correct
64 Correct 81 ms 384 KB Output is correct
65 Correct 83 ms 380 KB Output is correct
66 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
67 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 380 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 376 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 376 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 1 ms 376 KB Output is correct
28 Correct 1 ms 368 KB Output is correct
29 Correct 1 ms 376 KB Output is correct
30 Correct 1 ms 376 KB Output is correct
31 Correct 1 ms 376 KB Output is correct
32 Correct 1 ms 376 KB Output is correct
33 Correct 1 ms 368 KB Output is correct
34 Correct 1 ms 376 KB Output is correct
35 Correct 1 ms 376 KB Output is correct
36 Correct 13 ms 416 KB Output is correct
37 Correct 19 ms 368 KB Output is correct
38 Correct 115 ms 376 KB Output is correct
39 Correct 180 ms 504 KB Output is correct
40 Correct 253 ms 504 KB Output is correct
41 Correct 15 ms 384 KB Output is correct
42 Correct 17 ms 384 KB Output is correct
43 Correct 18 ms 384 KB Output is correct
44 Correct 20 ms 384 KB Output is correct
45 Correct 20 ms 376 KB Output is correct
46 Correct 23 ms 504 KB Output is correct
47 Correct 1 ms 384 KB Output is correct
48 Correct 16 ms 384 KB Output is correct
49 Correct 15 ms 384 KB Output is correct
50 Correct 13 ms 384 KB Output is correct
51 Correct 81 ms 384 KB Output is correct
52 Correct 98 ms 384 KB Output is correct
53 Correct 127 ms 504 KB Output is correct
54 Correct 138 ms 504 KB Output is correct
55 Correct 144 ms 512 KB Output is correct
56 Correct 156 ms 380 KB Output is correct
57 Correct 115 ms 512 KB Output is correct
58 Correct 111 ms 376 KB Output is correct
59 Correct 83 ms 384 KB Output is correct
60 Correct 71 ms 384 KB Output is correct
61 Correct 46 ms 504 KB Output is correct
62 Correct 28 ms 384 KB Output is correct
63 Correct 74 ms 384 KB Output is correct
64 Correct 81 ms 384 KB Output is correct
65 Correct 83 ms 380 KB Output is correct
66 Runtime error 1 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
67 Halted 0 ms 0 KB -