QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#640654#6260. Historic Exhibitionchanuuu#WA 1ms5140kbC++171.1kb2024-10-14 15:02:342024-10-14 15:02:35

Judging History

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

  • [2024-10-14 15:02:35]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5140kb
  • [2024-10-14 15:02:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int p, v;
int c[10101];
set<int> st[10101][3];

int main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    
    cin >> p >> v;
    for (int i = 1, a,b; i <= p; i++){
        cin >> a >> b;
        if (a > b) swap(a, b);
        if (a < b) {
            st[a][2].insert(i);
            st[b][0].insert(i);
        }
        else
            st[a][1].insert(i);
    }
    for (int i = 1; i <= v; i++) cin >> c[i];
    sort(c+1, c+1+v);
    vector<int> ans;
    for (int i = 1; i <= v; i++){
        int now = c[i], f = 0;
        for (int j = 0; j < 3; j++){
            if (st[now][j].empty()) continue;
            f = 1;
            auto it = st[now][j].begin();
            ans.push_back(*it);
            if (j != 1)
                st[now + (j == 2 ? 1 : -1)][2-j].erase(*it);
            st[now][j].erase(it);
            break;
        }
        if (!f){
            cout << "impossible";
            return 0;
        }
    }
    for (int i : ans)
        cout << i << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 4940kb

input:

4 3
1 2
4 5
2 3
2 2
1 2 3

output:

1
4
3

result:

ok correct

Test #2:

score: 0
Accepted
time: 1ms
memory: 5020kb

input:

2 2
1 1
2 3
1 1

output:

impossible

result:

ok impossible

Test #3:

score: 0
Accepted
time: 1ms
memory: 4956kb

input:

2 3
9 8
4 5
4 9 5

output:

impossible

result:

ok impossible

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 5140kb

input:

1000 1000
141 140
239 240
380 380
114 115
345 345
60 60
341 340
224 223
400 399
125 124
163 162
53 53
62 62
326 326
36 36
91 92
187 186
48 49
123 123
232 233
275 274
374 373
321 322
251 250
347 348
221 222
64 65
143 144
65 65
135 136
209 208
336 336
118 117
189 190
87 86
58 58
66 67
185 185
289 288
...

output:

247
842
157
873
872
513
330
390
657
387
197
887
405
992
775
269
444
161
72
233
368
459
504
757
669
118
166
340
837
904
450
714
836
323
535
218
898
262
642
303
396
711
360
438
484
602
116
245
789
903
588
41
119
238
373
668
271
569
773
526
979
446
921
187
278
502
709
192
254
691
80
312
520
905
427
957...

result:

wrong answer Sheet 247 does not contain colour 328!