답안 #801679

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
801679 2023-08-02T07:12:39 Z 반딧불(#10089) IOI 바이러스 (JOI21_fever) C++17
13 / 100
5000 ms 2688 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n;
int x[100002], y[100002];

int dir[100002];

int cnt;
bool on[100002];
vector<pair<int, int> > link[100002];
int ans;

void backtrack(int s){
    if(s==n+1){
        cnt = 0;
        for(int i=1; i<=n; i++) on[i] = 0, link[i].clear();

        for(int i=1; i<=n; i++){
            for(int j=1; j<=n; j++){
                if(x[i] > x[j]) continue;
                if(x[i] + y[i] == x[j] + y[j] && (dir[i] ^ dir[j]) == 3){
                    if((dir[i] == 0 && dir[j] == 3) || (dir[i] == 1 || dir[j] == 2)){
                        link[i].push_back(make_pair(j, x[j]-x[i]));
                        link[j].push_back(make_pair(i, x[j]-x[i]));
                    }
                }
                if(x[i] - y[i] == x[j] - y[j] && (dir[i] ^ dir[j]) == 1){
                    if((dir[i] == 3 && dir[j] == 2) || (dir[i] == 0 || dir[j] == 1)){
                        link[i].push_back(make_pair(j, x[j]-x[i]));
                        link[j].push_back(make_pair(i, x[j]-x[i]));
                    }
                }
            }
        }

        priority_queue<pair<int, int>, vector<pair<int, int> > , greater<pair<int, int> > > pq;
        pq.push(make_pair(0, 1));
        while(!pq.empty()){
            int x = pq.top().second, t = pq.top().first; pq.pop();
            if(on[x]) continue;
            on[x] = 1, cnt++;
            for(pair<int, int> y: link[x]){
                if(y.second < t) continue;
                pq.push(make_pair(y.second, y.first));
            }
        }
        ans = max(ans, cnt);
        return;
    }
    for(int d=0; d<4; d++){
        if(x[s] > x[1] && d==0) continue;
        if(y[s] < y[1] && d==1) continue;
        if(x[s] < x[1] && d==2) continue;
        if(y[s] > y[1] && d==3) continue;
        dir[s] = d;
        backtrack(s+1);
    }
}

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        scanf("%d %d", &x[i], &y[i]);
    }

    backtrack(1);

    printf("%d", ans);
}

Compilation message

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