답안 #595757

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
595757 2022-07-14T06:07:36 Z 조영욱(#8444) IOI 바이러스 (JOI21_fever) C++17
13 / 100
5000 ms 304 KB
#include <bits/stdc++.h>
using namespace std;

int n;
typedef pair<int,int> P;
P arr[16];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int dir[16];
int val[16];
int meet[16][16];
int dist[16];
bool vis[16];
const int INF=1e9+7;

int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
        scanf("%d %d",&arr[i].first,&arr[i].second);
    }
    for(int i=2;i<=n;i++) {
        if (arr[i].first>arr[1].first) {
            if (arr[i].second>arr[1].second) {
                dir[i]=2;
            }
            else {
                dir[i]=1;
            }
        }
        else {
            if (arr[i].second>arr[1].second) {
                dir[i]=3;
            }
            else {
                dir[i]=0;
            }
        }
    }
    int ret=0;
    for(int bit=0;bit<(2<<n);bit++) {
        val[1]=bit%4;
        for(int i=2;i<=n;i++) {
            if (bit&(1<<i)) {
                val[i]=(dir[i]+1)%4;
            }
            else {
                val[i]=dir[i];
            }
        }
        memset(meet,-1,sizeof(meet));
        for(int i=1;i<=n;i++) {
            for(int j=i+1;j<=n;j++) {
                if ((val[i]+val[j])%2==0) {
                    continue;
                }
                int t=abs(arr[i].first-arr[j].first);
                if (arr[i].first+dx[val[i]]*t==arr[j].first+dx[val[j]]*t) {
                    if (arr[i].second+dy[val[i]]*t==arr[j].second+dy[val[j]]*t) {
                        meet[i][j]=t;
                        meet[j][i]=t;
                    }
                }
            }
        }
        dist[1]=0;
        dist[0]=INF;
        for(int i=2;i<=n;i++) {
            dist[i]=INF;
        }
        memset(vis,0,sizeof(vis));
        int x=0;
        for(int i=1;i<=n;i++) {
            int now=0;
            for(int j=1;j<=n;j++) {
                if (!vis[j]&&dist[j]<dist[now]) {
                    now=j;
                }
            }
            if (now==0) {
                break;
            }
            x++;
            vis[now]=true;
            for(int j=1;j<=n;j++) {
                if (!vis[j]&&meet[now][j]!=-1&&meet[now][j]>dist[now]) {
                    dist[j]=min(dist[j],meet[now][j]);
                }
            }
        }
        ret=max(ret,x);
    }
    printf("%d",ret);
    return 0;
}

Compilation message

fever.cpp: In function 'int main()':
fever.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
fever.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         scanf("%d %d",&arr[i].first,&arr[i].second);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 304 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 304 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 41 ms 212 KB Output is correct
34 Correct 38 ms 212 KB Output is correct
35 Correct 36 ms 284 KB Output is correct
36 Correct 40 ms 280 KB Output is correct
37 Correct 60 ms 212 KB Output is correct
38 Correct 100 ms 288 KB Output is correct
39 Correct 83 ms 288 KB Output is correct
40 Correct 40 ms 212 KB Output is correct
41 Correct 48 ms 280 KB Output is correct
42 Correct 39 ms 212 KB Output is correct
43 Correct 39 ms 284 KB Output is correct
44 Correct 60 ms 284 KB Output is correct
45 Correct 62 ms 284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5086 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 304 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 41 ms 212 KB Output is correct
34 Correct 38 ms 212 KB Output is correct
35 Correct 36 ms 284 KB Output is correct
36 Correct 40 ms 280 KB Output is correct
37 Correct 60 ms 212 KB Output is correct
38 Correct 100 ms 288 KB Output is correct
39 Correct 83 ms 288 KB Output is correct
40 Correct 40 ms 212 KB Output is correct
41 Correct 48 ms 280 KB Output is correct
42 Correct 39 ms 212 KB Output is correct
43 Correct 39 ms 284 KB Output is correct
44 Correct 60 ms 284 KB Output is correct
45 Correct 62 ms 284 KB Output is correct
46 Execution timed out 5086 ms 212 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 304 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 41 ms 212 KB Output is correct
34 Correct 38 ms 212 KB Output is correct
35 Correct 36 ms 284 KB Output is correct
36 Correct 40 ms 280 KB Output is correct
37 Correct 60 ms 212 KB Output is correct
38 Correct 100 ms 288 KB Output is correct
39 Correct 83 ms 288 KB Output is correct
40 Correct 40 ms 212 KB Output is correct
41 Correct 48 ms 280 KB Output is correct
42 Correct 39 ms 212 KB Output is correct
43 Correct 39 ms 284 KB Output is correct
44 Correct 60 ms 284 KB Output is correct
45 Correct 62 ms 284 KB Output is correct
46 Execution timed out 5086 ms 212 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 304 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 41 ms 212 KB Output is correct
34 Correct 38 ms 212 KB Output is correct
35 Correct 36 ms 284 KB Output is correct
36 Correct 40 ms 280 KB Output is correct
37 Correct 60 ms 212 KB Output is correct
38 Correct 100 ms 288 KB Output is correct
39 Correct 83 ms 288 KB Output is correct
40 Correct 40 ms 212 KB Output is correct
41 Correct 48 ms 280 KB Output is correct
42 Correct 39 ms 212 KB Output is correct
43 Correct 39 ms 284 KB Output is correct
44 Correct 60 ms 284 KB Output is correct
45 Correct 62 ms 284 KB Output is correct
46 Execution timed out 5086 ms 212 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 304 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 304 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 41 ms 212 KB Output is correct
34 Correct 38 ms 212 KB Output is correct
35 Correct 36 ms 284 KB Output is correct
36 Correct 40 ms 280 KB Output is correct
37 Correct 60 ms 212 KB Output is correct
38 Correct 100 ms 288 KB Output is correct
39 Correct 83 ms 288 KB Output is correct
40 Correct 40 ms 212 KB Output is correct
41 Correct 48 ms 280 KB Output is correct
42 Correct 39 ms 212 KB Output is correct
43 Correct 39 ms 284 KB Output is correct
44 Correct 60 ms 284 KB Output is correct
45 Correct 62 ms 284 KB Output is correct
46 Execution timed out 5086 ms 212 KB Time limit exceeded
47 Halted 0 ms 0 KB -