codeForces_MinusAndMinusGivePlus
Posted cjn123
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了codeForces_MinusAndMinusGivePlus相关的知识,希望对你有一定的参考价值。
import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; /** * @author chenjiena * @version 1.0 * @created 2019-06-01 18:15 **/ public class MinusAndMinusGivePlus public static void main(String[] arg) Scanner in = new Scanner(System.in); int n = in.nextInt(); Queue<String> result = new LinkedList<String>(); for (int i=0;i<n;i++) Queue<Character> q1 = new LinkedList<Character>(); Queue<Character> q2 = new LinkedList<Character>(); int j = 0,k = 0; String s1 = in.next(); do q1.offer(s1.charAt(j)); ++j; while (j < s1.length() && s1.charAt(j) != ‘\\n‘); String s2 = in.next(); do q2.offer(s2.charAt(k)); ++k; while (k < s2.length() && s2.charAt(k) != ‘\\n‘); while (!q1.isEmpty() && !q2.isEmpty()) if (q1.peek() != q2.peek()) if (q1.peek() == ‘-‘) q1.poll(); if (!q1.isEmpty() && !q2.isEmpty()) if (q1.peek() == ‘-‘) q1.poll(); q2.poll(); else q2.poll(); if (q2.peek() == ‘-‘) q1.poll(); q1.poll(); else q1.poll(); q2.poll(); if (q1.isEmpty() && q2.isEmpty()) result.offer("YES"); else result.offer("NO"); while (!result.isEmpty()) System.out.println(result.poll());
以上是关于codeForces_MinusAndMinusGivePlus的主要内容,如果未能解决你的问题,请参考以下文章