Kevin234


私信TA

用户名:Kevin234

访问量:18861

签 名:

手可摘星辰

等  级
排  名 864
经  验 3449
参赛次数 0
文章发表 40
年  龄 0
在职情况 学生
学  校 南京信息工程大学
专  业

  自我简介:

解题思路:

注意事项:

测试数据中没有不能结束的情况

参考代码:

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;

public class P1879 {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(in.hasNext()) {
			Queue<Character> A = new LinkedList<Character>();
			Queue<Character> B = new LinkedList<Character>();
			Stack<Character> pk = new Stack<Character>();
			String a=in.next(),b=in.next();
			for(int i=0;i<a.length();i++) 
				A.offer(a.charAt(i));
			for(int j=0;j<b.length();j++)
				B.offer(b.charAt(j));
			while(!A.isEmpty() && !B.isEmpty()) {
				char c = A.poll();
				while(pk.contains(c)) {
					A.offer(c);
					int t = pk.size() - pk.indexOf(c);
					while(t-->0)
						A.offer(pk.pop());
					c=A.poll();
				}
				pk.push(c);
				if(A.isEmpty()) break;
				c = B.poll();
				while(pk.contains(c)) {
					B.offer(c);
					int t = pk.size() - pk.indexOf(c);
					while(t-->0)
						B.offer(pk.pop());
					c=B.poll();
				}
				pk.push(c);	
			}
			String regex = "[ ,\\[\\]]";
			if(A.isEmpty())
				System.out.println(B.toString().replaceAll(regex, ""));
			else
				System.out.println(A.toString().replaceAll(regex, ""));
		}
		in.close();
	}
}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

1024
2020-03-11 20:35:54
  • «
  • 1
  • »