SOLUTION INFO
C++ · main.cpp
- 작성자
- tony9402
- 공동 작성자
- 없음
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int T; cin >> T;
while(T--) {
string s; cin >> s;
bool flag = true;
int idx = 0, N = (int)s.size();
if(idx < N && 'B' <= s[idx] && s[idx] <= 'F') idx++;
for(char cur : {'A', 'F', 'C'}) {
int cnt = 0;
while(idx < N && s[idx] == cur) idx++, cnt++;
if(cnt == 0) flag = false;
}
if(idx < N && 'A' <= s[idx] && s[idx] <= 'F') idx++;
if(idx < N) flag = false;
if(flag) cout << "Infected!\n";
else cout << "Good\n";
}
return 0;
}
SOLUTION DESCRIPTION
풀이 설명
등록된 풀이 설명이 없습니다.
SOLUTION INFO
Java · Main.java
- 작성자
- lms0806
- 공동 작성자
- 없음
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException{
FastReader rd = new FastReader();
int size = rd.nextInt();
String str = "[A-F]?A+F+C+[A-F]?$";
StringBuilder sb = new StringBuilder();
while(size --> 0) {
sb.append(rd.nextLine().matches(str) ? "Infected!" : "Good").append("\n");
}
System.out.print(sb);
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while(st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble() { return Double.parseDouble(next()); }
String nextLine() {
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
}
SOLUTION DESCRIPTION
풀이 설명
등록된 풀이 설명이 없습니다.
SOLUTION INFO
Python · main.py
- 작성자
- tony9402
- 공동 작성자
- 없음
import sys
import re
def input():
return sys.stdin.readline().rstrip()
regex = re.compile('^[A-F]?A+F+C+[A-F]?$')
N = int(input())
for testcase in range(N):
line = input()
print("Infected!" if regex.match(line) else "Good")
SOLUTION DESCRIPTION
풀이 설명
등록된 풀이 설명이 없습니다.