QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#648333#1146. RailDimash0 20ms102700kbC++232.6kb2024-10-17 18:30:212024-10-17 18:30:22

Judging History

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

  • [2024-10-17 18:30:22]
  • 评测
  • 测评结果:0
  • 用时:20ms
  • 内存:102700kb
  • [2024-10-17 18:30:21]
  • 提交

answer

#include "rail.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 12;


int mem[N][N], c =0 ;
int get(int i, int j) {
    if(i == j) return 0;
    if(i > j) swap(i, j);
    if(mem[i][j] != -1) return mem[i][j];
    c++;
    return mem[i][j] = getDistance(i, j);
}
map<int, vector<int>> id;
void findLocation(int32_t n, int32_t first, int32_t pos[], int32_t s[]) {
    memset(mem, -1, sizeof(mem));
    for(int i = 0; i < n; i++) {
        s[i] = 0;
    }
    s[0] = 1;
    pos[0] = first;
    int L = 0;
    vector<pair<int, int>> a;
    for(int i = 1; i < n; i++) {
        a.push_back({get(0, i), i});
    }
    sort(a.rbegin(), a.rend());
    int R = a.back().second;
    int u = R;
    s[R] = 2;
    pos[R] = pos[0] + a.back().first;
    a.pop_back();
    reverse(a.begin(), a.end());
    for(auto [f, j]:a) {
        id[f].push_back(j);
    }
    cout << c << '\n';
    int prev = c;
    for(auto [f, vec]:id) {
        for(int j:vec) {
            if(!s[j]) {
                int mb = pos[R] - get(R, j);
                if(mb > pos[L]) {
                    int cur = R;
                    for(int i = 0; i < n; i++) {
                        if(s[i] == 2 && pos[i] < pos[cur] && pos[i] > mb) {
                            cur = i;
                        }
                    }
                    if(get(L, j) == pos[cur] * 2 - pos[L] - mb) {
                        s[j] = 1;
                        pos[j] = mb;
                    }
                }
            }
            if(!s[j]) {
                int mb = pos[L] + get(L, j);
                if(mb < pos[R]) {
                    int cur = L;
                    for(int i = 0; i < n; i++) {
                        if(s[i] == 1 && pos[i] > pos[cur] && pos[i] < mb) {
                            cur = i;
                        }
                    }
                    if(get(R, j) == pos[R] - pos[cur] + mb - pos[cur]) {
                        s[j] = 2;
                        pos[j] = mb;
                    }
                }
            }
            if(!s[j]) {
                int y = get(R, j);
                int mb = pos[R] - y;
                if(get(0, j) == pos[u] - pos[0] + pos[u] - mb) {
                    pos[j] = mb;
                    s[j] = 1;
                } else {
                    pos[j] = pos[L] + get(L, j);
                    s[j] = 2;
                }
            }
            if(s[j] == 1 && pos[j] < pos[L]) {
                L = j;            
            }
            if(s[j] == 2 && pos[j] > pos[R]) {
                R = j;
            }
        }
        prev = c;
    }
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 102136kb

input:

1
100
1 11
2 794
2 775
2 347
2 737
2 864
2 584
2 555
2 361
2 429
2 892
2 302
2 483
2 217
2 39
2 566
2 435
2 448
2 304
2 466
2 386
2 780
2 164
2 918
2 601
2 867
2 929
2 341
2 636
2 556
2 954
2 430
2 683
2 301
2 519
2 547
2 237
2 426
2 908
2 667
2 670
2 210
2 502
2 887
2 420
2 675
2 401
2 724
2 493
2 ...

output:

Unauthorized output

result:

wrong answer Token "Unauthorized" doesn't correspond to pattern "Correct"

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 0ms
memory: 101912kb

input:

2
100
1 7327
1 116
2 9993
1 2736
1 6502
1 4106
1 6326
2 8055
1 6767
1 388
2 7645
1 1780
1 6159
2 7738
1 3706
1 3476
2 9549
2 7564
1 2401
1 6353
2 8829
1 945
1 606
1 4664
2 9585
2 7499
1 6703
1 3229
1 1382
2 8286
1 6805
1 351
1 793
1 1641
1 3087
1 3647
1 2099
2 9414
1 1703
2 8866
2 9802
2 9348
1 6999...

output:

Unauthorized output

result:

wrong answer Token "Unauthorized" doesn't correspond to pattern "Correct"

Subtask #3:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 20ms
memory: 102700kb

input:

3
5000
1 763228
1 39310
2 962072
2 203549
1 85439
2 414565
2 78225
1 185073
2 174996
2 386604
1 662313
2 96651
1 271323
2 556033
1 788441
1 717148
1 404737
2 197742
2 760887
1 549658
2 713177
1 156708
1 858133
1 166177
1 809643
2 365041
1 73222
2 706708
2 296516
1 861386
1 782475
2 167675
1 100665
1...

output:

Unauthorized output

result:

wrong answer Token "Unauthorized" doesn't correspond to pattern "Correct"

Subtask #4:

score: 0
Wrong Answer

Test #31:

score: 0
Wrong Answer
time: 16ms
memory: 102576kb

input:

3
5000
1 763228
1 39310
2 962072
2 203549
1 85439
2 414565
2 78225
1 185073
2 174996
2 386604
1 662313
2 96651
1 271323
2 556033
1 788441
1 717148
1 404737
2 197742
2 760887
1 549658
2 713177
1 156708
1 858133
1 166177
1 809643
2 365041
1 73222
2 706708
2 296516
1 861386
1 782475
2 167675
1 100665
1...

output:

Unauthorized output

result:

wrong answer Token "Unauthorized" doesn't correspond to pattern "Correct"