๐ ์ฝ๋ฉํ ์คํธ ์ค๋น :: ๋ฐฑ์ค_14713:: ์คํ&ํ - ์ต๋ฌด์๐
14999 ๋จ์ด ์ฝ๋ฉํ
์คํธ์๋ฐ์ต๋ฌด์๋ฐฑ์ค๋ฐฑ์ค
๋ฌธ์
ํ์ด
ํ ์ต๋ฌด์๊ฐ ๋งํ๋ ๊ฒ์ ํ๋์ ํ์ ๋ฃ์ด์ค๋๋ค.
๊ทธ๋ฆฌ๊ณ ์ต๋ฌด์ ํ๋ฅผ ๋ฆฌ์คํธ์ ๋ด์์ค๋๋ค.
๊ทธ๋ฆฌ๊ณ cestream์ด ๋ฐ์์ ์ ๋ฌธ์ฅ์ ๊ณต๋ฐฑ ๋จ์๋ก ๋ฐ์์์ ๋ฆฌ์คํธ์ ์๋ ํ์ ํ์ธ์์ ์ ํฉ๋๋ค.ํ์ธ 1) cestream๊ณผ ๋ฆฌ์คํธ์ ์๋ ํ๋ฅผ ํ์ธ
ํ์ธ 2) cestream์ ์ง์์ก๋๋ฐ ์ต๋ฌด์ ํ๊ฐ ๋จ์๊ฒฝ์ฐํ์ธ 2๋๋ฌธ์ ์๊ฐ์ ์ข ๋ง์ด ํ๋น ํ๋ค.
์ฝ๋
import jdk.nashorn.internal.ir.WhileNode;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Bj14713_Parrot {
public static void main(String[] args) throws IOException {
ArrayList<Queue<String>> Plist = new ArrayList<>();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
for(int i = 0; i < n ; i++){
Queue<String> q = new LinkedList<>();
String string = br.readLine();
String[] st = string.split(" ");
for (int k = 0 ; k < st.length ; k++) {
q.offer(st[k]);
}
Plist.add(q);
}
String question = br.readLine();
String[] qArr = question.split(" ");
boolean f = true;
for (int i = 0; i < qArr.length; i++) {
if(!f) {
break;
}
for(int k = 0; k < Plist.size() ; k++) {
f = false;
if(!(Plist.get(k).isEmpty()) && Plist.get(k).peek().equals(qArr[i])){//0,
Plist.get(k).poll();
f = true;
break;
}
}
}
while (!Plist.isEmpty()) {
if(Plist.get(0).isEmpty()) {
Plist.remove(0);
}else{
break;
}
}
if(f && Plist.isEmpty()) {
System.out.println("Possible");
}else {
System.out.println("Impossible");
}
}
}
Author And Source
์ด ๋ฌธ์ ์ ๊ดํ์ฌ(๐ ์ฝ๋ฉํ ์คํธ ์ค๋น :: ๋ฐฑ์ค_14713:: ์คํ&ํ - ์ต๋ฌด์๐), ์ฐ๋ฆฌ๋ ์ด๊ณณ์์ ๋ ๋ง์ ์๋ฃ๋ฅผ ๋ฐ๊ฒฌํ๊ณ ๋งํฌ๋ฅผ ํด๋ฆญํ์ฌ ๋ณด์๋ค https://velog.io/@oh_yunseong/์ฝ๋ฉํ ์คํธ-์ค๋น-๋ฐฑ์ค14713-์คํํ-์ต๋ฌด์์ ์ ๊ท์: ์์์ ์ ๋ณด๊ฐ ์์์ URL์ ํฌํจ๋์ด ์์ผ๋ฉฐ ์ ์๊ถ์ ์์์ ์์ ์ ๋๋ค.
์ฐ์ํ ๊ฐ๋ฐ์ ์ฝํ ์ธ ๋ฐ๊ฒฌ์ ์ ๋ (Collection and Share based on the CC Protocol.)
์ข์ ์นํ์ด์ง ์ฆ๊ฒจ์ฐพ๊ธฐ
๊ฐ๋ฐ์ ์ฐ์ ์ฌ์ดํธ ์์ง
๊ฐ๋ฐ์๊ฐ ์์์ผ ํ ํ์ ์ฌ์ดํธ 100์ ์ถ์ฒ ์ฐ๋ฆฌ๋ ๋น์ ์ ์ํด 100๊ฐ์ ์์ฃผ ์ฌ์ฉํ๋ ๊ฐ๋ฐ์ ํ์ต ์ฌ์ดํธ๋ฅผ ์ ๋ฆฌํ์ต๋๋ค