Submission #595736

# Submission time Handle Problem Language Result Execution time Memory
595736 2022-07-14T04:59:32 Z 반딧불(#8442) IOI Fever (JOI21_fever) C++17
5 / 100
10 ms 812 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int xx[4] = {0, 1, 0, -1}, yy[]={1, 0, -1, 0};

int n;
int x[10], y[10];
int dir[10];
int ans;
bool taken[10];

struct dat{
    int x, y, t;
    dat(){}
    dat(int x, int y, int t): x(x), y(y), t(t){}
    bool operator<(const dat &r)const{
        return t>r.t;
    }
};

int solve(){
    for(int i=1; i<=n; i++){
        taken[i] = (i==1);
    }
    priority_queue<dat> pq;
    for(int i=1; i<=n; i++){
        for(int j=i+1; j<=n; j++){
            if(dir[i]%2 == dir[j]%2) continue;
            int a = i, b = j;
            if(dir[a]%2 == 0) swap(a, b); /// a:Ȧ, b:¦
            if(dir[a] == 1){
                if(dir[b]==2 && x[a]-y[a]==x[b]-y[b]) pq.push(dat(a, b, x[b]-x[a]));
                if(dir[b]==0 && x[a]+y[a]==x[b]+y[b]) pq.push(dat(a, b, x[b]-x[a]));
            }
            if(dir[a] == 3){
                if(dir[b]==0 && x[a]-y[a]==x[b]-y[b]) pq.push(dat(a, b, x[a]-x[b]));
                if(dir[b]==2 && x[a]+y[a]==x[b]+y[b]) pq.push(dat(a, b, x[a]-x[b]));
            }
        }
    }
    while(!pq.empty()){
        dat tmp = pq.top(); pq.pop();
        if(tmp.t <= 0) continue;
        if(taken[tmp.y]) swap(tmp.x, tmp.y);
        if(taken[tmp.x]) taken[tmp.y] = 1;
    }
    return count(taken+1, taken+n+1, true);
}

void dfs(int x){
    if(x==n+1){
        ans = max(ans, solve());
        return;
    }
    for(int i=0; i<4; i++){
        dir[x] = i;
        dfs(x+1);
    }
}

int main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        scanf("%d %d", &x[i], &y[i]);
    }
    dfs(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]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 0 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 1 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 5 ms 212 KB Output is correct
17 Correct 5 ms 212 KB Output is correct
18 Correct 4 ms 212 KB Output is correct
19 Correct 6 ms 212 KB Output is correct
20 Correct 4 ms 212 KB Output is correct
21 Correct 4 ms 212 KB Output is correct
22 Correct 4 ms 300 KB Output is correct
23 Correct 4 ms 212 KB Output is correct
24 Correct 9 ms 296 KB Output is correct
25 Correct 10 ms 304 KB Output is correct
26 Correct 8 ms 296 KB Output is correct
27 Correct 8 ms 212 KB Output is correct
28 Correct 5 ms 296 KB Output is correct
29 Correct 6 ms 340 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 9 ms 212 KB Output is correct
32 Correct 6 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 0 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 1 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 5 ms 212 KB Output is correct
17 Correct 5 ms 212 KB Output is correct
18 Correct 4 ms 212 KB Output is correct
19 Correct 6 ms 212 KB Output is correct
20 Correct 4 ms 212 KB Output is correct
21 Correct 4 ms 212 KB Output is correct
22 Correct 4 ms 300 KB Output is correct
23 Correct 4 ms 212 KB Output is correct
24 Correct 9 ms 296 KB Output is correct
25 Correct 10 ms 304 KB Output is correct
26 Correct 8 ms 296 KB Output is correct
27 Correct 8 ms 212 KB Output is correct
28 Correct 5 ms 296 KB Output is correct
29 Correct 6 ms 340 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 9 ms 212 KB Output is correct
32 Correct 6 ms 212 KB Output is correct
33 Incorrect 0 ms 212 KB Output isn't correct
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 812 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 0 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 1 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 5 ms 212 KB Output is correct
17 Correct 5 ms 212 KB Output is correct
18 Correct 4 ms 212 KB Output is correct
19 Correct 6 ms 212 KB Output is correct
20 Correct 4 ms 212 KB Output is correct
21 Correct 4 ms 212 KB Output is correct
22 Correct 4 ms 300 KB Output is correct
23 Correct 4 ms 212 KB Output is correct
24 Correct 9 ms 296 KB Output is correct
25 Correct 10 ms 304 KB Output is correct
26 Correct 8 ms 296 KB Output is correct
27 Correct 8 ms 212 KB Output is correct
28 Correct 5 ms 296 KB Output is correct
29 Correct 6 ms 340 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 9 ms 212 KB Output is correct
32 Correct 6 ms 212 KB Output is correct
33 Incorrect 0 ms 212 KB Output isn't correct
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 0 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 1 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 5 ms 212 KB Output is correct
17 Correct 5 ms 212 KB Output is correct
18 Correct 4 ms 212 KB Output is correct
19 Correct 6 ms 212 KB Output is correct
20 Correct 4 ms 212 KB Output is correct
21 Correct 4 ms 212 KB Output is correct
22 Correct 4 ms 300 KB Output is correct
23 Correct 4 ms 212 KB Output is correct
24 Correct 9 ms 296 KB Output is correct
25 Correct 10 ms 304 KB Output is correct
26 Correct 8 ms 296 KB Output is correct
27 Correct 8 ms 212 KB Output is correct
28 Correct 5 ms 296 KB Output is correct
29 Correct 6 ms 340 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 9 ms 212 KB Output is correct
32 Correct 6 ms 212 KB Output is correct
33 Incorrect 0 ms 212 KB Output isn't correct
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 0 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 1 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 5 ms 212 KB Output is correct
17 Correct 5 ms 212 KB Output is correct
18 Correct 4 ms 212 KB Output is correct
19 Correct 6 ms 212 KB Output is correct
20 Correct 4 ms 212 KB Output is correct
21 Correct 4 ms 212 KB Output is correct
22 Correct 4 ms 300 KB Output is correct
23 Correct 4 ms 212 KB Output is correct
24 Correct 9 ms 296 KB Output is correct
25 Correct 10 ms 304 KB Output is correct
26 Correct 8 ms 296 KB Output is correct
27 Correct 8 ms 212 KB Output is correct
28 Correct 5 ms 296 KB Output is correct
29 Correct 6 ms 340 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 9 ms 212 KB Output is correct
32 Correct 6 ms 212 KB Output is correct
33 Incorrect 0 ms 212 KB Output isn't correct
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 0 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 1 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 5 ms 212 KB Output is correct
17 Correct 5 ms 212 KB Output is correct
18 Correct 4 ms 212 KB Output is correct
19 Correct 6 ms 212 KB Output is correct
20 Correct 4 ms 212 KB Output is correct
21 Correct 4 ms 212 KB Output is correct
22 Correct 4 ms 300 KB Output is correct
23 Correct 4 ms 212 KB Output is correct
24 Correct 9 ms 296 KB Output is correct
25 Correct 10 ms 304 KB Output is correct
26 Correct 8 ms 296 KB Output is correct
27 Correct 8 ms 212 KB Output is correct
28 Correct 5 ms 296 KB Output is correct
29 Correct 6 ms 340 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 9 ms 212 KB Output is correct
32 Correct 6 ms 212 KB Output is correct
33 Incorrect 0 ms 212 KB Output isn't correct
34 Halted 0 ms 0 KB -