Submission #801046

# Submission time Handle Problem Language Result Execution time Memory
801046 2023-08-02T04:13:24 Z 반딧불(#10089) IOI Fever (JOI21_fever) C++17
5 / 100
5000 ms 2668 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++){
        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:61:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
fever.cpp:63:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         scanf("%d %d", &x[i], &y[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 2 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 2 ms 2656 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 1 ms 2656 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 4 ms 2664 KB Output is correct
17 Correct 4 ms 2660 KB Output is correct
18 Correct 4 ms 2668 KB Output is correct
19 Correct 4 ms 2644 KB Output is correct
20 Correct 4 ms 2660 KB Output is correct
21 Correct 4 ms 2644 KB Output is correct
22 Correct 4 ms 2644 KB Output is correct
23 Correct 4 ms 2656 KB Output is correct
24 Correct 6 ms 2644 KB Output is correct
25 Correct 5 ms 2644 KB Output is correct
26 Correct 6 ms 2644 KB Output is correct
27 Correct 6 ms 2644 KB Output is correct
28 Correct 5 ms 2644 KB Output is correct
29 Correct 4 ms 2644 KB Output is correct
30 Correct 1 ms 2644 KB Output is correct
31 Correct 6 ms 2644 KB Output is correct
32 Correct 4 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 2 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 2 ms 2656 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 1 ms 2656 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 4 ms 2664 KB Output is correct
17 Correct 4 ms 2660 KB Output is correct
18 Correct 4 ms 2668 KB Output is correct
19 Correct 4 ms 2644 KB Output is correct
20 Correct 4 ms 2660 KB Output is correct
21 Correct 4 ms 2644 KB Output is correct
22 Correct 4 ms 2644 KB Output is correct
23 Correct 4 ms 2656 KB Output is correct
24 Correct 6 ms 2644 KB Output is correct
25 Correct 5 ms 2644 KB Output is correct
26 Correct 6 ms 2644 KB Output is correct
27 Correct 6 ms 2644 KB Output is correct
28 Correct 5 ms 2644 KB Output is correct
29 Correct 4 ms 2644 KB Output is correct
30 Correct 1 ms 2644 KB Output is correct
31 Correct 6 ms 2644 KB Output is correct
32 Correct 4 ms 2644 KB Output is correct
33 Execution timed out 5021 ms 2556 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5060 ms 2644 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 2 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 2 ms 2656 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 1 ms 2656 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 4 ms 2664 KB Output is correct
17 Correct 4 ms 2660 KB Output is correct
18 Correct 4 ms 2668 KB Output is correct
19 Correct 4 ms 2644 KB Output is correct
20 Correct 4 ms 2660 KB Output is correct
21 Correct 4 ms 2644 KB Output is correct
22 Correct 4 ms 2644 KB Output is correct
23 Correct 4 ms 2656 KB Output is correct
24 Correct 6 ms 2644 KB Output is correct
25 Correct 5 ms 2644 KB Output is correct
26 Correct 6 ms 2644 KB Output is correct
27 Correct 6 ms 2644 KB Output is correct
28 Correct 5 ms 2644 KB Output is correct
29 Correct 4 ms 2644 KB Output is correct
30 Correct 1 ms 2644 KB Output is correct
31 Correct 6 ms 2644 KB Output is correct
32 Correct 4 ms 2644 KB Output is correct
33 Execution timed out 5021 ms 2556 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 2 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 2 ms 2656 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 1 ms 2656 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 4 ms 2664 KB Output is correct
17 Correct 4 ms 2660 KB Output is correct
18 Correct 4 ms 2668 KB Output is correct
19 Correct 4 ms 2644 KB Output is correct
20 Correct 4 ms 2660 KB Output is correct
21 Correct 4 ms 2644 KB Output is correct
22 Correct 4 ms 2644 KB Output is correct
23 Correct 4 ms 2656 KB Output is correct
24 Correct 6 ms 2644 KB Output is correct
25 Correct 5 ms 2644 KB Output is correct
26 Correct 6 ms 2644 KB Output is correct
27 Correct 6 ms 2644 KB Output is correct
28 Correct 5 ms 2644 KB Output is correct
29 Correct 4 ms 2644 KB Output is correct
30 Correct 1 ms 2644 KB Output is correct
31 Correct 6 ms 2644 KB Output is correct
32 Correct 4 ms 2644 KB Output is correct
33 Execution timed out 5021 ms 2556 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 2 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 2 ms 2656 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 1 ms 2656 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 4 ms 2664 KB Output is correct
17 Correct 4 ms 2660 KB Output is correct
18 Correct 4 ms 2668 KB Output is correct
19 Correct 4 ms 2644 KB Output is correct
20 Correct 4 ms 2660 KB Output is correct
21 Correct 4 ms 2644 KB Output is correct
22 Correct 4 ms 2644 KB Output is correct
23 Correct 4 ms 2656 KB Output is correct
24 Correct 6 ms 2644 KB Output is correct
25 Correct 5 ms 2644 KB Output is correct
26 Correct 6 ms 2644 KB Output is correct
27 Correct 6 ms 2644 KB Output is correct
28 Correct 5 ms 2644 KB Output is correct
29 Correct 4 ms 2644 KB Output is correct
30 Correct 1 ms 2644 KB Output is correct
31 Correct 6 ms 2644 KB Output is correct
32 Correct 4 ms 2644 KB Output is correct
33 Execution timed out 5021 ms 2556 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 2 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 2 ms 2656 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 1 ms 2656 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 4 ms 2664 KB Output is correct
17 Correct 4 ms 2660 KB Output is correct
18 Correct 4 ms 2668 KB Output is correct
19 Correct 4 ms 2644 KB Output is correct
20 Correct 4 ms 2660 KB Output is correct
21 Correct 4 ms 2644 KB Output is correct
22 Correct 4 ms 2644 KB Output is correct
23 Correct 4 ms 2656 KB Output is correct
24 Correct 6 ms 2644 KB Output is correct
25 Correct 5 ms 2644 KB Output is correct
26 Correct 6 ms 2644 KB Output is correct
27 Correct 6 ms 2644 KB Output is correct
28 Correct 5 ms 2644 KB Output is correct
29 Correct 4 ms 2644 KB Output is correct
30 Correct 1 ms 2644 KB Output is correct
31 Correct 6 ms 2644 KB Output is correct
32 Correct 4 ms 2644 KB Output is correct
33 Execution timed out 5021 ms 2556 KB Time limit exceeded
34 Halted 0 ms 0 KB -