QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#100436#5680. You You See What?Nicolas125841AC ✓145ms39968kbJava111.1kb2023-04-26 07:45:032023-04-26 07:45:06

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-26 07:45:06]
  • 评测
  • 测评结果:AC
  • 用时:145ms
  • 内存:39968kb
  • [2023-04-26 07:45:03]
  • 提交

answer

import java.io.*;
import java.util.*;

public class SmallPath {

	public static void main(String args[]) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		
		String[] tags = br.readLine().split("!");		
		Stack<Pair<String>> sol = new Stack<>();
		
		for(int i = 0; i < tags.length; i++) {
			String tag = tags[i];
			
			if(sol.isEmpty())
				sol.push(new Pair<String>("", tag));
			else if(sol.peek().first.toLowerCase().compareTo(tag.toLowerCase()) == 0)
				sol.pop();
			else if(i == tags.length-1 || sol.peek().second.toLowerCase().compareTo(tag.toLowerCase()) != 0)
				sol.push(new Pair<String>(sol.peek().second, tag));		
		}
		
		String fin = sol.pop().second;
		
		while(!sol.empty()) 
			fin = sol.pop().second + "!" + fin;
		
		
		pw.println(fin);
		pw.close();
	}
	
	static class Pair<T>{
		T first, second;
		
		public Pair(T f, T s) {
			first = f;
			second = s;
		}
		
		@Override
		public String toString() {
			return first + " -> " + second;
		}
	}
}

詳細信息

Test #1:

score: 100
Accepted
time: 102ms
memory: 39456kb

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: 108ms
memory: 39180kb

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: 116ms
memory: 39568kb

input:

bresearch!bpoucher

output:

bresearch!bpoucher

result:

ok single line: 'bresearch!bpoucher'

Test #4:

score: 0
Accepted
time: 117ms
memory: 39828kb

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: 119ms
memory: 39792kb

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: 145ms
memory: 39888kb

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: 96ms
memory: 39284kb

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: 111ms
memory: 39248kb

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: 134ms
memory: 39588kb

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: 99ms
memory: 39968kb

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: 61ms
memory: 35696kb

input:

b

output:

b

result:

ok single line: 'b'

Test #12:

score: 0
Accepted
time: 68ms
memory: 35196kb

input:

bpoucher

output:

bpoucher

result:

ok single line: 'bpoucher'

Test #13:

score: 0
Accepted
time: 53ms
memory: 35688kb

input:

Abcdefghij

output:

Abcdefghij

result:

ok single line: 'Abcdefghij'

Test #14:

score: 0
Accepted
time: 102ms
memory: 39412kb

input:

polyof!johnb

output:

polyof!johnb

result:

ok single line: 'polyof!johnb'

Test #15:

score: 0
Accepted
time: 102ms
memory: 39196kb

input:

polyvm!polyof!gracie!johnb

output:

polyvm!polyof!gracie!johnb

result:

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

Test #16:

score: 0
Accepted
time: 113ms
memory: 39636kb

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: 119ms
memory: 39160kb

input:

aaaa!bbbbb!bbbbb!testacct

output:

aaaa!bbbbb!testacct

result:

ok single line: 'aaaa!bbbbb!testacct'

Test #18:

score: 0
Accepted
time: 139ms
memory: 39736kb

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: 95ms
memory: 39384kb

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: 100ms
memory: 39800kb

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: 106ms
memory: 39436kb

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'