QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#640881 | #6260. Historic Exhibition | BaBamBa# | WA | 1ms | 3752kb | C++17 | 1.4kb | 2024-10-14 16:40:43 | 2024-10-14 16:40:44 |
Judging History
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;
bool check = false;
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);
}
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
{
check = true;
//cout << "impossible\n";
//return 0;
}
}
if(check)
cout << "impossible\n";
else{
for (auto &x : ans)
cout << x << '\n';
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3524kb
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: 3476kb
input:
2 2 1 1 2 3 1 1
output:
impossible
result:
ok impossible
Test #3:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
2 3 9 8 4 5 4 9 5
output:
impossible
result:
ok impossible
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3688kb
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