QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#175695#5680. You You See What?yyc4591AC ✓2ms3568kbC++141.6kb2023-09-10 21:37:342023-09-10 21:37:35

Judging History

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

  • [2023-09-10 21:37:35]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3568kb
  • [2023-09-10 21:37:34]
  • 提交

answer

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

map<string, int>mp;
int id = 1;
map<int, string>src;

void deal(string &s)
{
	for(auto &it : s)
	{
		if(it == '!')
			it = ' ';
	}	
}

string convert(string t)
{
	string s = t;
	for(auto &it : s)
		if(it >= 'A' && it <= 'Z')
			it = it - 'A' + 'a';
	return s;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	string s; cin >> s;
	deal(s);
	
	vector<int>v; v.clear();
	stringstream is(s);
	
	auto print = [&]()
	{
		cout << src[v[0]];
		for(int i = 1; i <v.size(); i++)
			cout << "!" << src[v[i]];
		cout << endl;
	};

	string t;
	while(is >> t)
	{
		string str = convert(t);

		if(!mp.count(str)) {
			src[id] = t;
			mp[str] = id++;
		}
		v.push_back(mp[str]);
	}

	int n = v.size();
	while(1)
	{
		int len = 1, loc = -1;
		for(int i = 0; i < n - 1; i++)
		{
			int sum = 1, cnt;
			if(v[i] == v[i + 1]) {
				for(cnt = 0; i - cnt >= 0 && i + cnt + 1 < n - 1; cnt++)
					if(v[i - cnt] != v[i + cnt + 1])
						break;
				sum = max(cnt * 2, sum);	
			}

			else {
				for(cnt = 1; i - cnt >= 0 && i + cnt < n - 1; cnt++)
					if(v[cnt + i] != v[i - cnt])
						break;
				sum = max(sum, cnt * 2 - 1);
			}

			if(sum > len) {
				len = sum;
				loc = i;
			}
		}

		// cout << len << " " << loc << endl;
		if(loc == -1)break;

		int st, ed;
		if(v[loc] == v[loc + 1]) {
			st = loc - len/2 + 2;
			ed = loc + len/2 + 1;
		}
		
		else {
			st = loc - len / 2 + 1;
			ed = loc + len / 2 + 1;
		}

		v.erase(v.begin() + st, v.begin() + ed);
		n = v.size();
		// print();
	}

	print();
	
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3464kb

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: 0
Accepted
time: 1ms
memory: 3484kb

input:

texasam!Rice!baYlor!csdept!BayloR!dev!Rice!bresearch!bpoucher

output:

texasam!Rice!baYlor!dev!Rice!bresearch!bpoucher

result:

ok single line: 'texasam!Rice!baYlor!dev!Rice!bresearch!bpoucher'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3452kb

input:

bresearch!bpoucher

output:

bresearch!bpoucher

result:

ok single line: 'bresearch!bpoucher'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3452kb

input:

a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x

output:

a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x

result:

ok single line: 'a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!...i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x'

Test #5:

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

input:

a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!xx

output:

a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!xx

result:

ok single line: 'a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!...!j!k!l!m!n!o!p!q!r!s!t!u!v!w!xx'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3560kb

input:

a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z

output:

a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z

result:

ok single line: 'a!b!c!d!e!f!g!h!i!j!k!l!m!n!o!...k!l!m!n!o!p!q!r!s!t!u!v!w!x!y!z'

Test #7:

score: 0
Accepted
time: 1ms
memory: 3524kb

input:

abcdEFGHij!bbcdEFGHij!cbcdEFGHij!dbcdEFGHij!ebcdEFGHij!fbcdEFGHij!gbcdEFGHij!hbcdEFGHij!ibcdEFGHij!jbcdEFGHij!kbcdEFGHij!lbcdEFGHij!mbcdEFGHij!nbcdEFGHij!obcdEFGHij!pbcdEFGHij!qbcdEFGHij!rbcdEFGHij!sbcdEFGHij!tbcdEFGHij!ubcdEFGHij!vbcdEFGHij!wbcdEFGHij!abc

output:

abcdEFGHij!bbcdEFGHij!cbcdEFGHij!dbcdEFGHij!ebcdEFGHij!fbcdEFGHij!gbcdEFGHij!hbcdEFGHij!ibcdEFGHij!jbcdEFGHij!kbcdEFGHij!lbcdEFGHij!mbcdEFGHij!nbcdEFGHij!obcdEFGHij!pbcdEFGHij!qbcdEFGHij!rbcdEFGHij!sbcdEFGHij!tbcdEFGHij!ubcdEFGHij!vbcdEFGHij!wbcdEFGHij!abc

result:

ok single line: 'abcdEFGHij!bbcdEFGHij!cbcdEFGH...FGHij!vbcdEFGHij!wbcdEFGHij!abc'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3452kb

input:

abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abcdEFGHij!abc

output:

abcdEFGHij!abc

result:

ok single line: 'abcdEFGHij!abc'

Test #9:

score: 0
Accepted
time: 1ms
memory: 3548kb

input:

a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!bb

output:

a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!a!bb

result:

ok single line: 'a!b!c!a!b!c!a!b!c!a!b!c!a!b!c!...!c!a!b!c!a!b!c!a!b!c!a!b!c!a!bb'

Test #10:

score: 0
Accepted
time: 1ms
memory: 3516kb

input:

aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!Bb!Aa!BB!aA!bB!aa!bB!aA!BB!Aa!B

output:

aa!B

result:

ok single line: 'aa!B'

Test #11:

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

input:

b

output:

b

result:

ok single line: 'b'

Test #12:

score: 0
Accepted
time: 1ms
memory: 3516kb

input:

bpoucher

output:

bpoucher

result:

ok single line: 'bpoucher'

Test #13:

score: 0
Accepted
time: 1ms
memory: 3448kb

input:

Abcdefghij

output:

Abcdefghij

result:

ok single line: 'Abcdefghij'

Test #14:

score: 0
Accepted
time: 1ms
memory: 3480kb

input:

polyof!johnb

output:

polyof!johnb

result:

ok single line: 'polyof!johnb'

Test #15:

score: 0
Accepted
time: 1ms
memory: 3424kb

input:

polyvm!polyof!gracie!johnb

output:

polyvm!polyof!gracie!johnb

result:

ok single line: 'polyvm!polyof!gracie!johnb'

Test #16:

score: 0
Accepted
time: 1ms
memory: 3452kb

input:

a!b!b!c!c!d!d!d!e!e!e

output:

a!b!c!d!e!e

result:

ok single line: 'a!b!c!d!e!e'

Test #17:

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

input:

aaaa!bbbbb!bbbbb!testacct

output:

aaaa!bbbbb!testacct

result:

ok single line: 'aaaa!bbbbb!testacct'

Test #18:

score: 0
Accepted
time: 1ms
memory: 3568kb

input:

a!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b

output:

a!b!b

result:

ok single line: 'a!b!b'

Test #19:

score: 0
Accepted
time: 1ms
memory: 3532kb

input:

a!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!bb!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b

output:

a!b!b

result:

ok single line: 'a!b!b'

Test #20:

score: 0
Accepted
time: 1ms
memory: 3552kb

input:

a!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!c!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b

output:

a!b!b

result:

ok single line: 'a!b!b'

Test #21:

score: 0
Accepted
time: 2ms
memory: 3460kb

input:

a!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!c!d!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b!b

output:

a!b!c!d!b!b

result:

ok single line: 'a!b!c!d!b!b'