QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#640855#6260. Historic ExhibitionBaBamBa#WA 1ms3860kbC++171.3kb2024-10-14 16:31:392024-10-14 16:31:40

Judging History

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

  • [2024-10-14 16:31:40]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3860kb
  • [2024-10-14 16:31:39]
  • 提交

answer

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

using ll = long long;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll N, M;
    cin >> N >> M;
    vector<pair<ll, ll>> inp(N);
    map<pair<ll, ll>, vector<ll>> m;
    map<pair<ll, ll>, ll> ind;
    for (int i = 0; i < N; i++)
    {
        cin >> inp[i].first >> inp[i].second;
        if (inp[i].first > inp[i].second)
            swap(inp[i].first, inp[i].second);
        m[inp[i]].push_back(i + 1);
    }

    sort(inp.begin(), inp.end());
    vector<ll> vis(N);
    vector<ll> ans;
    for (int i = 0; i < M; i++)
    {
        ll a;
        cin >> a;

        if (ind[{a - 1, a}] < m[{a - 1, a}].size())
        {
            ans.push_back(m[{a - 1, a}][ind[{a - 1, a}]]);
            ind[{a - 1, a}]++;
        }
        else if (ind[{a, a}] < m[{a, a}].size())
        {
            ans.push_back(m[{a, a}][ind[{a, a}]]);
            ind[{a, a}]++;
        }
        else if (ind[{a, a + 1}] < m[{a, a + 1}].size())
        {
            ans.push_back(m[{a, a + 1}][ind[{a, a + 1}]]);
            ind[{a, a + 1}]++;
        }
        else
        {
            cout << "impossible";
            return 0;
        }
    }
    for (auto &x : ans)
        cout << x << '\n';
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3652kb

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: 0ms
memory: 3560kb

input:

2 2
1 1
2 3
1 1

output:

impossible

result:

ok impossible

Test #3:

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

input:

2 3
9 8
4 5
4 9 5

output:

impossible

result:

ok impossible

Test #4:

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

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:

impossible

result:

wrong output format Expected integer, but "impossible" found