답안 #122967

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
122967 2019-06-29T17:41:46 Z CaroLinda 열대 식물원 (Tropical Garden) (IOI11_garden) C++17
100 / 100
2902 ms 20932 KB
#include <bits/stdc++.h>
#include "gardenlib.h"
#include "garden.h"

#define lp(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back

const int MAXN = 15e4+10;
const int MAXM = 15e4+10 ;
const int MAXQ = 2005 ;
const int inf=0x3f3f3f3f ;

using namespace std;

int p ;
int graph[MAXN*2] ;
vector<int> v[MAXN] ;

bool marc[MAXN*2][2] ;
int checking,d[MAXN*2][2] ;

void dfs(int x, int y)
{
    if(marc[x][y]) return ;
    marc[x][y] = 1 ;
    dfs(graph[x],y) ;
    if(x!=2*p+y)
    d[x][y] = d[graph[x]][y]+1 ;
}

bool mod(int x, int y , int z)
{
    if( y == inf || x<y || (x-y)%z!=0 ) return false ;
    return true ;
}

void count_routes(int n, int m, int P, int r[][2], int q, int g[])
{
    p=P ;

    lp(i,0,m)
    lp(j,0,2)
    v[ r[i][j] ].pb(r[i][!j]) ;

    lp(i,0,n)
    if(v[i].size() == 1) v[i].pb(v[i][0]) ;

    lp(i,0,n)
    if(v[i].size() != 0)
    {
        if( i == v[v[i][0]][0] )
            graph[2*i] = 2*v[i][0]+1 ;
        else graph[2*i]=2*v[i][0] ;
        if( i == v[v[i][1]][0] )
            graph[2*i+1]=2*v[i][1]+1 ;
        else graph[2*i+1]=2*v[i][1];
    }

    lp(i,0,MAXN*2) d[i][0] = d[i][1]=inf ;
    lp(i,0,2) d[2*p+i][i] = 0 ;
    lp(i,0,2) dfs(2*p+i, i) ;
    lp(i,0,2*n) dfs(i,0) , dfs(i,1) ;

   int cycle[2] = { d[graph[2*p]][0]+1, d[graph[2*p+1]][1]+1 } ;

   lp(i,0,q)
   {
       int ans =0  ;
       for(int j = 0 ; j<2*n ; j+=2)
        if(mod(g[i],d[j][0],cycle[0]) || mod(g[i],d[j][1],cycle[1])) ans ++ ;
        answer(ans) ;
   }

}

Compilation message

garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:72:8: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
        for(int j = 0 ; j<2*n ; j+=2)
        ^~~
garden.cpp:74:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
         answer(ans) ;
         ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 6364 KB Output is correct
2 Correct 8 ms 6264 KB Output is correct
3 Correct 8 ms 6264 KB Output is correct
4 Correct 8 ms 6264 KB Output is correct
5 Correct 7 ms 6140 KB Output is correct
6 Correct 8 ms 6392 KB Output is correct
7 Correct 7 ms 6136 KB Output is correct
8 Correct 9 ms 6264 KB Output is correct
9 Correct 10 ms 6392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 6364 KB Output is correct
2 Correct 8 ms 6264 KB Output is correct
3 Correct 8 ms 6264 KB Output is correct
4 Correct 8 ms 6264 KB Output is correct
5 Correct 7 ms 6140 KB Output is correct
6 Correct 8 ms 6392 KB Output is correct
7 Correct 7 ms 6136 KB Output is correct
8 Correct 9 ms 6264 KB Output is correct
9 Correct 10 ms 6392 KB Output is correct
10 Correct 7 ms 6180 KB Output is correct
11 Correct 18 ms 7544 KB Output is correct
12 Correct 32 ms 8572 KB Output is correct
13 Correct 49 ms 18556 KB Output is correct
14 Correct 94 ms 13372 KB Output is correct
15 Correct 102 ms 13532 KB Output is correct
16 Correct 107 ms 11912 KB Output is correct
17 Correct 75 ms 11304 KB Output is correct
18 Correct 32 ms 8564 KB Output is correct
19 Correct 101 ms 13348 KB Output is correct
20 Correct 105 ms 13560 KB Output is correct
21 Correct 84 ms 11740 KB Output is correct
22 Correct 79 ms 11260 KB Output is correct
23 Correct 101 ms 14164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 6364 KB Output is correct
2 Correct 8 ms 6264 KB Output is correct
3 Correct 8 ms 6264 KB Output is correct
4 Correct 8 ms 6264 KB Output is correct
5 Correct 7 ms 6140 KB Output is correct
6 Correct 8 ms 6392 KB Output is correct
7 Correct 7 ms 6136 KB Output is correct
8 Correct 9 ms 6264 KB Output is correct
9 Correct 10 ms 6392 KB Output is correct
10 Correct 7 ms 6180 KB Output is correct
11 Correct 18 ms 7544 KB Output is correct
12 Correct 32 ms 8572 KB Output is correct
13 Correct 49 ms 18556 KB Output is correct
14 Correct 94 ms 13372 KB Output is correct
15 Correct 102 ms 13532 KB Output is correct
16 Correct 107 ms 11912 KB Output is correct
17 Correct 75 ms 11304 KB Output is correct
18 Correct 32 ms 8564 KB Output is correct
19 Correct 101 ms 13348 KB Output is correct
20 Correct 105 ms 13560 KB Output is correct
21 Correct 84 ms 11740 KB Output is correct
22 Correct 79 ms 11260 KB Output is correct
23 Correct 101 ms 14164 KB Output is correct
24 Correct 9 ms 6216 KB Output is correct
25 Correct 126 ms 7652 KB Output is correct
26 Correct 177 ms 8708 KB Output is correct
27 Correct 1579 ms 18604 KB Output is correct
28 Correct 1443 ms 13512 KB Output is correct
29 Correct 2074 ms 13540 KB Output is correct
30 Correct 1200 ms 12048 KB Output is correct
31 Correct 1113 ms 11328 KB Output is correct
32 Correct 196 ms 8484 KB Output is correct
33 Correct 1466 ms 13388 KB Output is correct
34 Correct 1996 ms 13536 KB Output is correct
35 Correct 1190 ms 11788 KB Output is correct
36 Correct 1866 ms 11264 KB Output is correct
37 Correct 1072 ms 14412 KB Output is correct
38 Correct 2902 ms 20932 KB Output is correct