답안 #122968

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
122968 2019-06-29T17:43:21 Z CaroLinda 열대 식물원 (Tropical Garden) (IOI11_garden) C++14
100 / 100
3708 ms 21072 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 7 ms 6268 KB Output is correct
3 Correct 8 ms 6236 KB Output is correct
4 Correct 7 ms 6264 KB Output is correct
5 Correct 7 ms 6236 KB Output is correct
6 Correct 8 ms 6396 KB Output is correct
7 Correct 9 ms 6264 KB Output is correct
8 Correct 9 ms 6304 KB Output is correct
9 Correct 8 ms 6396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 6364 KB Output is correct
2 Correct 7 ms 6268 KB Output is correct
3 Correct 8 ms 6236 KB Output is correct
4 Correct 7 ms 6264 KB Output is correct
5 Correct 7 ms 6236 KB Output is correct
6 Correct 8 ms 6396 KB Output is correct
7 Correct 9 ms 6264 KB Output is correct
8 Correct 9 ms 6304 KB Output is correct
9 Correct 8 ms 6396 KB Output is correct
10 Correct 7 ms 6156 KB Output is correct
11 Correct 18 ms 7544 KB Output is correct
12 Correct 30 ms 8576 KB Output is correct
13 Correct 49 ms 18512 KB Output is correct
14 Correct 94 ms 13296 KB Output is correct
15 Correct 95 ms 13524 KB Output is correct
16 Correct 79 ms 11848 KB Output is correct
17 Correct 79 ms 11284 KB Output is correct
18 Correct 35 ms 8464 KB Output is correct
19 Correct 105 ms 13436 KB Output is correct
20 Correct 110 ms 13524 KB Output is correct
21 Correct 81 ms 11896 KB Output is correct
22 Correct 89 ms 11228 KB Output is correct
23 Correct 110 ms 14160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 6364 KB Output is correct
2 Correct 7 ms 6268 KB Output is correct
3 Correct 8 ms 6236 KB Output is correct
4 Correct 7 ms 6264 KB Output is correct
5 Correct 7 ms 6236 KB Output is correct
6 Correct 8 ms 6396 KB Output is correct
7 Correct 9 ms 6264 KB Output is correct
8 Correct 9 ms 6304 KB Output is correct
9 Correct 8 ms 6396 KB Output is correct
10 Correct 7 ms 6156 KB Output is correct
11 Correct 18 ms 7544 KB Output is correct
12 Correct 30 ms 8576 KB Output is correct
13 Correct 49 ms 18512 KB Output is correct
14 Correct 94 ms 13296 KB Output is correct
15 Correct 95 ms 13524 KB Output is correct
16 Correct 79 ms 11848 KB Output is correct
17 Correct 79 ms 11284 KB Output is correct
18 Correct 35 ms 8464 KB Output is correct
19 Correct 105 ms 13436 KB Output is correct
20 Correct 110 ms 13524 KB Output is correct
21 Correct 81 ms 11896 KB Output is correct
22 Correct 89 ms 11228 KB Output is correct
23 Correct 110 ms 14160 KB Output is correct
24 Correct 10 ms 6236 KB Output is correct
25 Correct 127 ms 7544 KB Output is correct
26 Correct 166 ms 8696 KB Output is correct
27 Correct 1700 ms 18588 KB Output is correct
28 Correct 1414 ms 13420 KB Output is correct
29 Correct 2069 ms 13540 KB Output is correct
30 Correct 1107 ms 11932 KB Output is correct
31 Correct 1313 ms 11348 KB Output is correct
32 Correct 188 ms 8480 KB Output is correct
33 Correct 1427 ms 13508 KB Output is correct
34 Correct 1998 ms 13524 KB Output is correct
35 Correct 1144 ms 11780 KB Output is correct
36 Correct 1985 ms 11260 KB Output is correct
37 Correct 1044 ms 14404 KB Output is correct
38 Correct 3708 ms 21072 KB Output is correct