QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#37604#4251. Gamejli5052 10ms39172kbC++202.5kb2022-07-02 12:14:032022-07-02 12:14:05

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-07-02 12:14:05]
  • 评测
  • 测评结果:2
  • 用时:10ms
  • 内存:39172kb
  • [2022-07-02 12:14:03]
  • 提交

answer

#include <bits/stdc++.h>
#include "game.h"
using namespace std;

void fastIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

int N, K;

bool good = false;
int earl[21][300100], late[21][300100];
vector<int> g[300100], rev[300100];

void build(int node, int l, int r, int h){
    for (int i = l; i <= r; i++){
        earl[h][i] = late[h][i] = node;
    }
    if (l == r){
        return;
    }
    int mid = (l+r)/2;
    build(node*2, l, mid, h+1);
    build(node*2+1, mid+1, r, h+1);
}

void init(int n, int k){
    N = n, K = k;
    build(1, 1, K, 1);
}

void dfs(int node, int val, int h){
    if (late[h][node] == 0 || late[h][node] < val){
        late[h][node] = val;
    } else {
        return;
    }
    for (int nx : g[node]){
        dfs(nx, val, h);
    }
}

void dfs2(int node, int val, int h){
    if (earl[h][node] == 0 || earl[h][node] > val){
        earl[h][node] = val;
    } else {
        return;
    }
    for (int nx : rev[node]){
        dfs2(nx, val, h);
    }
}

void dnq(int node, int l, int r, int u, int v, int h){
    if (l == r){
        if (late[h][u] == node){
            dfs(v, late[h][u], h);
        }
        if (earl[h][v] == node){
            dfs2(u, earl[h][v], h);
        }
        if (u > K && earl[h][u] == late[h][u] && earl[h][u]) good = true;
        if (v > K && earl[h][v] == late[h][v] && earl[h][v]) good = true;
        return;
    }
    int mid = (l+r)/2;
    if (late[h+1][u] == node*2 || late[h+1][u] == node*2+1){
        dfs(v, late[h+1][u], h+1);
    }
    if (earl[h+1][v] == node*2 || earl[h+1][v] == node*2+1){
        dfs2(u, earl[h+1][v], h+1);
    }

    if (u > K && earl[h+1][u] && late[h+1][u] && earl[h+1][u] < late[h+1][u]){
        good = true;
    }
    if (v > K && earl[h+1][v] && late[h+1][v] && earl[h+1][v] < late[h+1][v]){
        good = true;
    }
    if ((earl[h+1][u] == node*2 && earl[h+1][u] == earl[h+1][v]) || (late[h+1][u] == node*2 && late[h+1][u] == late[h+1][v])){
        dnq(node*2, l, mid, u, v, h+1);
    } else if ((earl[h+1][u] == node*2+1 && earl[h+1][u] == earl[h+1][v]) || (late[h+1][u] == node*2+1 && late[h+1][u] == late[h+1][v])){
        dnq(node*2+1, mid+1, r, u, v, h+1);
    }
}

int add_teleporter(int u, int v){
    u++, v++;
    if (good) return 1;
    if (u <= K && v <= K && u >= v){
        good = true;
        return 1;
    }
    g[u].push_back(v);
    rev[v].push_back(u);
    dnq(1, 1, K, u, v, 1);
    if (good) return 1;
    return 0;
}

详细

Subtask #1:

score: 2
Accepted

Test #1:

score: 2
Accepted
time: 3ms
memory: 22740kb

input:

1 1
1
893123 893123
-1

output:

0

result:

ok interaction finished.

Test #2:

score: 0
Accepted
time: 10ms
memory: 31252kb

input:

9 9
29
893122 893124
893121 893127
893120 893124
893123 893121
893122 893131
893125 893131
893121 893126
893123 893126
893126 893131
893123 893131
893123 893125
893123 893124
893127 893125
893120 893126
893123 893120
893121 893131
893123 893127
893122 893126
893122 893127
893127 893131
893122 893125...

output:

28

result:

ok interaction finished.

Test #3:

score: 0
Accepted
time: 2ms
memory: 39172kb

input:

100 100
80
893180 893071
893134 893063
893150 893091
893127 893178
893142 893177
893153 893156
893127 893137
893174 893065
893127 893070
893126 893061
893171 893089
893173 893072
893153 893058
893156 893074
893151 893068
893136 893060
893120 893083
893073 893091
893148 893163
893073 893088
893156 89...

output:

80
80
80
59

result:

ok interaction finished.

Test #4:

score: 0
Accepted
time: 3ms
memory: 34340kb

input:

45 45
80
893143 893167
893122 893132
893123 893140
893120 893139
893158 893167
893154 893163
893133 893137
893133 893142
893135 893137
893121 893135
893137 893149
893141 893152
893122 893167
893128 893145
893140 893167
893122 893127
893134 893142
893122 893129
893141 893156
893146 893149
893123 8931...

output:

80
49

result:

ok interaction finished.

Test #5:

score: 0
Accepted
time: 4ms
memory: 38536kb

input:

100 100
80
893169 893058
893132 893065
893143 893068
893153 893167
893152 893182
893138 893162
893129 893163
893146 893164
893134 893180
893142 893167
893144 893059
893132 893064
893135 893091
893164 893068
893123 893179
893126 893060
893136 893140
893179 893081
893139 893181
893120 893057
893172 89...

output:

80
80
80
42

result:

ok interaction finished.

Test #6:

score: 0
Accepted
time: 2ms
memory: 38248kb

input:

100 100
80
893135 893081
893170 893076
893148 893075
893134 893159
893159 893073
893170 893088
893131 893138
893121 893166
893171 893168
893127 893137
893147 893145
893062 893076
893160 893059
893063 893088
893137 893073
893123 893182
893152 893170
893141 893172
893137 893087
893167 893085
893147 89...

output:

80
80
80
37

result:

ok interaction finished.

Test #7:

score: 0
Accepted
time: 0ms
memory: 38952kb

input:

100 100
80
893062 893075
893139 893156
893137 893083
893071 893075
893072 893080
893141 893060
893126 893179
893064 893081
893167 893077
893139 893165
893056 893085
893169 893182
893062 893087
893141 893078
893062 893078
893129 893176
893065 893077
893141 893181
893152 893158
893151 893078
893157 89...

output:

80
80
80
59

result:

ok interaction finished.

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #8:

score: 10
Accepted
time: 2ms
memory: 30948kb

input:

100 10
80
893135 893150
893174 893168
893159 893149
893162 893082
893158 893129
893072 893150
893088 893079
893155 893154
893086 893126
893078 893153
893177 893138
893057 893066
893151 893089
893076 893162
893165 893164
893085 893170
893084 893128
893074 893083
893138 893148
893147 893167
893071 893...

output:

80
31

result:

ok interaction finished.

Test #9:

score: 0
Accepted
time: 2ms
memory: 33788kb

input:

100 10
80
893087 893068
893090 893073
893077 893169
893159 893156
893170 893062
893081 893145
893076 893083
893128 893078
893132 893139
893181 893165
893155 893167
893167 893089
893065 893081
893068 893180
893150 893175
893066 893183
893060 893133
893086 893060
893072 893142
893084 893132
893151 893...

output:

80
10

result:

ok interaction finished.

Test #10:

score: 0
Accepted
time: 2ms
memory: 31140kb

input:

100 10
80
893136 893078
893085 893075
893173 893143
893132 893066
893066 893074
893149 893080
893152 893148
893179 893146
893174 893137
893082 893077
893140 893082
893080 893134
893171 893149
893070 893161
893087 893132
893168 893059
893086 893085
893159 893153
893143 893173
893167 893140
893062 893...

output:

80
25

result:

ok interaction finished.

Test #11:

score: 0
Accepted
time: 3ms
memory: 37936kb

input:

100 50
80
893180 893088
893174 893057
893168 893177
893080 893064
893061 893060
893086 893065
893169 893168
893182 893069
893079 893068
893177 893089
893064 893176
893175 893084
893068 893072
893076 893063
893071 893087
893074 893078
893070 893082
893090 893179
893179 893182
893063 893071
893173 893...

output:

80
19

result:

ok interaction finished.

Test #12:

score: 0
Accepted
time: 5ms
memory: 34964kb

input:

100 25
80
893065 893138
893153 893124
893163 893132
893121 893173
893170 893183
893128 893162
893063 893084
893174 893128
893163 893124
893148 893127
893127 893167
893146 893153
893157 893152
893077 893154
893067 893135
893174 893146
893156 893058
893120 893066
893151 893128
893087 893139
893144 893...

output:

80
80
80
14

result:

ok interaction finished.

Test #13:

score: 0
Accepted
time: 4ms
memory: 30028kb

input:

100 10
80
893171 893168
893173 893067
893132 893173
893060 893178
893062 893064
893077 893171
893135 893081
893089 893134
893091 893064
893086 893156
893173 893181
893133 893071
893070 893076
893154 893069
893172 893182
893138 893091
893151 893149
893162 893085
893132 893136
893125 893083
893173 893...

output:

80
80
80
13

result:

ok interaction finished.

Test #14:

score: 0
Accepted
time: 4ms
memory: 37692kb

input:

100 50
80
893171 893179
893169 893074
893139 893091
893159 893168
893078 893171
893162 893064
893080 893174
893125 893067
893156 893087
893152 893061
893063 893183
893069 893170
893086 893170
893154 893181
893069 893090
893131 893069
893075 893164
893088 893171
893131 893066
893154 893083
893153 893...

output:

80
80
80
9

result:

ok interaction finished.

Test #15:

score: -10
Wrong Answer
time: 6ms
memory: 34404kb

input:

100 48
80
893089 893176
893085 893129
893129 893176
893083 893129
893141 893061
893083 893064
893166 893176
893064 893073
893141 893176
893085 893141
893085 893083
893061 893089
893073 893061
893129 893089
893129 893061
893141 893089
893073 893166
893083 893141
893166 893061
893083 893166
893129 893...

output:

80
69

result:

wrong answer Wrong Answer [1]

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%