QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#112190 | #5673. Cornhole | PetroTarnavskyi# | WA | 2ms | 3488kb | C++17 | 1.5kb | 2023-06-10 15:48:02 | 2023-06-10 15:48:20 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))
const int N = 447;
VI g[N];
string ans[N];
map<string, int> m;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
string s;
cin >> s;
string t = "", t2 = "";
int prev = -1;
FOR (i, 0, SZ(s))
{
if (s[i] == '!')
{
int x = m.count(t2) ? m[t2] : SZ(m);
m[t2] = x;
if (prev != -1) g[prev].PB(x);
prev = x;
ans[x] = t;
t = t2 = "";
}
else
{
t += s[i];
t2 += tolower(s[i]);
}
}
int x = m.count(t2) ? m[t2] : SZ(m);
g[prev].PB(x);
m[t2] = x;
ans[x] = t;
VI d(SZ(m), 100);
VI p(SZ(m), -1);
queue<int> q;
q.push(0);
d[0] = 0;
while (!q.empty())
{
int v = q.front();
q.pop();
for (auto to : g[v])
{
if (d[to] > d[v] + 1)
{
d[to] = d[v] + 1;
q.push(to);
p[to] = v;
}
}
}
VI path;
while (p[x] != -1)
{
path.PB(x);
x = p[x];
}
path.PB(x);
reverse(ALL(path));
FOR (i, 0, SZ(path))
{
if (i) cout << '!';
cout << ans[path[i]];
}
cout << '\n';
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3488kb
input:
2 1 0 4
output:
2
result:
wrong answer 1st lines differ - expected: '1 3', found: '2'