QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#112192#5680. You You See What?PetroTarnavskyi#WA 2ms3440kbC++171.5kb2023-06-10 15:52:492023-06-10 15:52:53

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-10 15:52:53]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3440kb
  • [2023-06-10 15:52:49]
  • 提交

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), 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: 100
Accepted
time: 0ms
memory: 3440kb

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: 3428kb

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'