QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#125710#92. Santa ClausQwerty12320 931ms14628kbC++205.6kb2023-07-17 13:20:272023-07-17 13:20:30

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-17 13:20:30]
  • 评测
  • 测评结果:0
  • 用时:931ms
  • 内存:14628kb
  • [2023-07-17 13:20:27]
  • 提交

answer

#pragma GCC optimize("O3")
// #pragma GCC target("avx512vl,avx512dq,avx512bw")
#pragma GCC target("avx2")
#include <cassert>
#include <iostream>
void* operator new(size_t s) {
    constexpr static int MEM = 1e8;
    static char data[MEM];
    static size_t ptr = 0;
    ptr += s;
    assert(ptr <= MEM);
    return data + ptr - s;
}

void operator delete(void*) { ; }
#include <bits/stdc++.h>

std::mt19937 rnd;

void solve() {
    int n;
    std::cin >> n;
    std::vector<int> x(n), h(n), v(n);
    for (int i = 0; i < n; i++) {
        std::cin >> x[i];
    }
    for (int i = 0; i < n; i++) {
        std::cin >> h[i];
    }
    for (int i = 0; i < n; i++) {
        std::cin >> v[i];
    }
    std::vector<int> s;
    for (int i = 0; i < n; i++) {
        if (h[i] == 0) {
            s.push_back(v[i]);
        }
    }
    std::sort(s.begin(), s.end());
    for (int i = 0; i < n; i++) {
        int it = std::lower_bound(s.begin(), s.end(), v[i]) - s.begin();
        it += 5;
        v[i] = it;
        // if (h[i] == 0) {
        // } else {
        //     ;
        // }
    }

    if (n - std::accumulate(h.begin(), h.end(), 0) > n / 2) {
        assert(false);
        for (int i = 0; i < n; i++) {
            std::cout << -1 << " \n"[i == n - 1];
        }
        return;
    }

    int it = h.rend() - std::find(h.rbegin(), h.rend(), 0) - 1;
    if (it == -1) {
        assert(false);
        for (int i = 0; i < n; i++) {
            std::cout << x[i] << " \n"[i == n - 1];
        }
        return;
    }

    std::vector<int> ans(n, -1);
    std::vector<uint16_t> cum, fuck;
    for (int i = 0; i <= it; i++) {
        if (h[i] == 0) {
            cum.push_back(v[i]);
        } else {
            fuck.push_back(v[i]);
        }
    }
    while (it < n && cum.size() > fuck.size()) {
        fuck.push_back(v[it]);
        it++;
    }
    std::sort(fuck.begin(), fuck.end());
    std::sort(cum.begin(), cum.end());

    int x_left = -1;
    int left = 0;
    std::multiset<int> set;
    for (int i = it; i < n; i++) {
        if (h[i] == 1) {
            auto it = std::lower_bound(fuck.begin(), fuck.end(), v[i]);
            fuck.insert(it, v[i]);
        }

        auto check = [&]() {
            if (fuck.size() >= cum.size()) {
                uint16_t cnt = 0;
                for (int i = 0; i < 100; i++) {
                    int id = rnd() % cum.size();
                    if (fuck[id] > cum[id]) {
                        return false;
                    }
                }
                constexpr int G = 1 << 10;
                if (1) {
#pragma GCC ivdep
                    for (int i = 0; i < cum.size(); i++) {
                        cnt += fuck[i] > cum[i];
                        if (i + G < cum.size()) {
#pragma GCC ivdep
                            for (int j = 0; j < G; j++) {
                                cnt += fuck[i + j] > cum[i + j];
                            }
                            if (cnt > 0) {
                                break;
                            }
                            i += G - 1;
                        }
                    }
                } else {
#pragma GCC ivdep
                    for (int i = cum.size() - 1; i >= 0; i--) {
                        cnt += fuck[i] > cum[i];
                        if (i > G) {
#pragma GCC ivdep
                            for (int j = 0; j < G; j++) {
                                cnt += fuck[i - j] > cum[i - j];
                            }
                            if (cnt > 0) {
                                break;
                            }
                            i -= G - 1;
                        }
                    }
                }
                return cnt == 0;
            }
            return false;
        };

        if (x_left != left && fuck.size() >= cum.size() && check()) {
            x_left = left;
        }

        while (x_left == left && fuck.size() >= cum.size() && left < i) {
            if (h[left] == 0) {
                set.insert(v[left]);
                left++;
                x_left++;
                continue;
            }
            int val_ch = v[left];
            int it = std::lower_bound(fuck.begin(), fuck.end(), val_ch) - fuck.begin();
            fuck.erase(fuck.begin() + it);
            left++;

            // std::pair<int, int> min(1.1e9, -1);
            // for (int i = 0; i < left; i++) {
            //     if (h[i] == 0 && v[i] >= val_ch) {
            //         min = std::min(min, {v[i], i});
            //     }
            // }
            auto it1 = set.lower_bound(val_ch);

            if (it1 == set.end()) {
                if (it >= cum.size()) {
                    x_left = left;
                    continue;
                }
                if (check()) {
                    x_left = left;
                    continue;
                }
                break;
            } else {
                // v[min.second] = -1;
                auto it = std::lower_bound(cum.begin(), cum.end(), *it1);
                cum.erase(it);
                set.erase(it1);

                x_left = left;
            }
        }

        if (x_left != -1) {
            ans[i] = x[i] * 2 - x[x_left];
        }
    }
    for (int i = 0; i < n; i++) {
        std::cout << ans[i] << " \n"[i == n - 1];
    }
}

int32_t main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t;
    std::cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3420kb

input:

5
84
25 26 31 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 90 94 102 105 112 117 125 134 140 146 147 156 157 167 173 183 186 187 190 198 206 212 220 224 226 234 235 240 250 251 259 261 268 271
1 0 0 0 0 0...

output:

-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 187 190 198 206 212 220 224 226 234 235 240 250 251 259 261 268 271
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -...

result:

wrong answer 1st lines differ - expected: '-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...235 240 250 251 259 261 268 271', found: '-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...235 240 250 251 259 261 268 271'

Test #2:

score: 0
Wrong Answer
time: 1ms
memory: 3500kb

input:

10
134
105 106 107 108 109 110 111 112 113 114 115 116 117 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 1...

output:

-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 246 247 248 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 19...

result:

wrong answer 3rd lines differ - expected: '-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...459 461 469 475 484 489 494 502', found: '-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...459 461 469 475 484 489 494 502'

Test #3:

score: 0
Wrong Answer
time: 5ms
memory: 3896kb

input:

10
1379
85 86 151 152 155 156 157 158 159 160 161 162 163 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 23...

output:

-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

result:

wrong answer 1st lines differ - expected: '-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...7 3206 3209 3216 3223 3232 3241', found: '-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...7 3206 3209 3216 3223 3232 3241'

Test #4:

score: 0
Wrong Answer
time: 11ms
memory: 4396kb

input:

10
2709
75 76 81 88 89 119 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 2...

output:

-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

result:

wrong answer 4th lines differ - expected: '-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...3 6479 6484 6485 6488 6493 6502', found: '-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...3 6479 6484 6485 6488 6493 6502'

Test #5:

score: 0
Wrong Answer
time: 22ms
memory: 6496kb

input:

10
5562
75 76 81 88 89 119 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 2...

output:

-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

result:

wrong answer 1st lines differ - expected: '-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...3 12703 12706 12707 12714 12719', found: '-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...3 12703 12706 12707 12714 12719'

Test #6:

score: 0
Wrong Answer
time: 56ms
memory: 7384kb

input:

10
13123
75 76 81 88 89 119 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 ...

output:

-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

result:

wrong answer 2nd lines differ - expected: '-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...2 33629 33633 33638 33645 33651', found: '-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...2 33629 33633 33638 33645 33651'

Test #7:

score: 0
Wrong Answer
time: 183ms
memory: 10176kb

input:

10
27599
75 76 81 88 89 119 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 ...

output:

-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

result:

wrong answer 1st lines differ - expected: '-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...5 62161 62170 62177 62181 62183', found: '-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...5 62161 62170 62177 62181 62183'

Test #8:

score: 0
Wrong Answer
time: 419ms
memory: 13428kb

input:

10
41646
75 76 81 88 89 119 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 ...

output:

-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

result:

wrong answer 1st lines differ - expected: '-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...0 94273 94282 94292 94295 94299', found: '-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...0 94273 94282 94292 94295 94299'

Test #9:

score: 0
Wrong Answer
time: 931ms
memory: 14628kb

input:

10
95045
75 76 81 88 89 119 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 ...

output:

-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

result:

wrong answer 3rd lines differ - expected: '-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...2 71259 71262 71271 71279 71285', found: '-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...2 71259 71262 71271 71279 71285'

Test #10:

score: 0
Time Limit Exceeded

input:

10
96068
75 76 81 88 89 119 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 ...

output:

-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

result: