import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb=new StringBuffer();
while(true){
int round=Integer.parseInt(br.readLine());
if(round==-1){
break;
}
sb.append("Round ").append(round).append("\n");
String ans=br.readLine();
String chosen=br.readLine();
int[]should=new int[26];
for(int i=0;i<ans.length();i++){
should[ans.charAt(i)-97]++;
}
int correct=0;
int wrong=0;
boolean[]cb=new boolean[26];
for(int i=0;i<chosen.length();i++){
int ind=chosen.charAt(i)-97;
if(!cb[ind]){
if(should[ind]>0){
correct+=should[ind];
}
else{
wrong++;
}
if(correct==ans.length()){
break;
}
if(wrong==7){
break;
}
cb[ind]=true;
}
}
if(correct==ans.length()){
sb.append("You win.\n");
}else if(wrong==7){
sb.append("You lose.\n");
}else{
sb.append("You chickened out.\n");
}
}
System.out.print(sb);
}
}
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb=new StringBuffer();
while(true){
int round=Integer.parseInt(br.readLine());
if(round==-1){
break;
}
sb.append("Round ").append(round).append("\n");
String ans=br.readLine();
String chosen=br.readLine();
int[]should=new int[26];
for(int i=0;i<ans.length();i++){
should[ans.charAt(i)-97]++;
}
int correct=0;
int wrong=0;
boolean[]cb=new boolean[26];
for(int i=0;i<chosen.length();i++){
int ind=chosen.charAt(i)-97;
if(!cb[ind]){
if(should[ind]>0){
correct+=should[ind];
}
else{
wrong++;
}
if(correct==ans.length()){
break;
}
if(wrong==7){
break;
}
cb[ind]=true;
}
}
if(correct==ans.length()){
sb.append("You win.\n");
}else if(wrong==7){
sb.append("You lose.\n");
}else{
sb.append("You chickened out.\n");
}
}
System.out.print(sb);
}
}
No comments:
Post a Comment