QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#112206 | #5680. You You See What? | PetroTarnavskyi# | WA | 2ms | 3540kb | C++17 | 1.5kb | 2023-06-10 16:34:47 | 2023-06-10 16:34:49 |
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;
s += '!';
string t = "", t2 = "";
int prev = -1;
int x;
FOR (i, 0, SZ(s))
{
if (s[i] == '!')
{
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]);
}
}
VI d(SZ(m), N);
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: 100
Accepted
time: 2ms
memory: 3516kb
input:
texasam!rice!baylor!csdept!baylor!rice!dev!bresearch!bpoucher
output:
texasam!rice!dev!bresearch!bpoucher
result:
ok single line: 'texasam!rice!dev!bresearch!bpoucher'
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3540kb
input:
texasam!Rice!baYlor!csdept!BayloR!dev!Rice!bresearch!bpoucher
output:
texasam!Rice!bresearch!bpoucher
result:
wrong answer 1st lines differ - expected: 'texasam!Rice!baYlor!dev!Rice!bresearch!bpoucher', found: 'texasam!Rice!bresearch!bpoucher'