Search is not available for this dataset
name
stringlengths
2
88
description
stringlengths
31
8.62k
public_tests
dict
private_tests
dict
solution_type
stringclasses
2 values
programming_language
stringclasses
5 values
solution
stringlengths
1
983k
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
java
import java.util.*; import java.util.regex.Pattern; public class Main { public void doIt(){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for(int i=0; i < n; i++){ String str = sc.next(); boolean result = Pattern.matches(">'(=+)#(=)+\\~", str); if(result){ String str1 = str.replaceAll...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> using namespace std; int main(){ int n; cin >> n; while(n--){ int i,eq1,eq2; string ret = "NA"; string s; cin >> s; if(s.substr(0,3) == ">'="){ i = 2; eq1 = 0; while(s[i] == '=' && i < s.length() )i++,eq1++; if(s[i] != '#')goto label; i++; eq2 = 0; while(s[i] ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> //#include <fstream> #define NA cout << "NA" << endl; goto LABEL using namespace std; int main() { //ifstream fin("in.txt"); int snakeCount; cin >> snakeCount; for(int loopCount = 0; loopCount < snakeCount; loopCount++) { char arr[202]; cin >> arr; int i = 0; if(arr[i]!='>') { N...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <string> using namespace std; bool isA( string& s ) { int ptr = 0; if( s.size() < 6 || s[ 0 ] != '>' || s[ 1 ] != '\'' || s[ s.size() - 1 ] != '~' ){ return false; } ptr = 2; while( ptr < s.size() - 1 && s[ ptr ] == '=' ){ ++ptr; } if( s[ ptr ] != '#' ){ return false; } int ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int Tc; cin >> Tc; while(Tc--) { string S; cin >> S; LA: { string s = S; if(s.size() < 6) goto BAD; if(s.substr(0, 3) != ">'=") goto LB; if(s[s.size()-1] != '~') goto BAD; s = s.substr(2); ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
python2
def snakeA(s): if s.startswith(">'") and s.endswith("~"): if s.count("#")==1: t=s[2:-1].split("#") if len(t)==2 and t[0]==t[1]: if set(list(t[0]))==set(list(t[1]))==set(["="]): return True return False def snakeB(s): if s.startswith(">^") ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(void){ int n; cin>>n; for (int i=0;i<n;i++) { string s; cin>>s; if (s.size()<6||s.size()%2!=0){ cout<<"NA"<<endl; } else { if (s.at(0)=='>'&&s.at(1)=='\''&&s.at(s.size()-1)=='~') { ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> #include<string> using namespace std; bool check(string s,int n) { if (s.size() <= n)return true; return false; } void solve() { string s; cin >> s; int n = 0; if (s[n] == '>') { n++; if (check(s, n)); else if (s[n] == '\'') { n++; int cnt = 0; while (s[n] == '=' && !check(s, n)) ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <sstream> #include <string> #include <vector> #include <set> #include <map> #include <stack> #include <queue> #include <algorithm> #include <numeric> #include <functional> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <climits> using namespace std; typed...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <string> using namespace std; bool kind_a(string str){ if(str[0] != '>' || str[1] != '\'' || str[str.size()-1] != '~'){ return false; } string su = str.substr(2, str.size()-3); if(su.size()<3) return false; for(int i=0; i<su.size(); ++i){ int j = su.size()-1-i; ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
// 2011/10/02 Tazoe #include <iostream> #include <string> using namespace std; int main() { int n; cin >> n; for(int i=0; i<n; i++){ string str; cin >> str; if(str[0]!='>'){ cout << "NA" << endl; continue; } if(str[1]=='\''){ int N = 0; int I = 2; while(str[I]=='='){ N++; I++; ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> #include<string> using namespace std; int main() { int n,f,i,m; string s; cin>>n; while(n-->0){ cin>>s; f=0; if(s[0]=='>' && s[1]=='\''){ m=s.find('#'); if(m!=string::npos){ for(i=1;s[m-i]==s[m+i];)i++; if(i>1 && m-i==1 && m+i==s.size()-1 && s[m+i]=='~')f=1; }...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <cstdio> #include <iostream> #include <string> #include <algorithm> #define int long long #define rep(i, n) for (int i=0; i<n; i++) #define REP(n) rep(i, n) using namespace std; int n; string snake, head, tail, body; signed main() { cin >> n; REP(n) { cin >> snake; if (snak...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <string> #include <cstdio> using namespace std; enum { A, B, NA }; int f(string s){ if(s.size() < 6) return NA; if(s.substr(0,2)==">'"){ size_t i=2; while(i<s.size() && s[i]=='=') i++; if(i==2 || i==s.size() || s[i]!='#') return NA; size_t j=i+1; ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <string> using namespace std; int main() { int n; cin >> n; for(int i=0;i<n;i++){ bool a=false,b=false; string str; cin >> str; if(str[0] == '>' && str[1] == '\'' && str.size()%2==0 && str.size() >= 6){a = true;} if(str[0] == '>' && str[1] == '^' && str.size()%2==0 && str.size...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> #include<string> using namespace std; int checkA(string); int checkB(string); int main(){ int i, n; string snake; cin >> n; for(i=0; i<n; ++i){ cin >> snake; if(checkA(snake) == 1) cout << "A" << endl; else if(checkB(snake) == 1) cout << "B" << endl; else ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <vector> #include <list> #include <map> #include <set> #include <stack> #include <queue> #include <deque> #include <algorithm> #include <utility> #include <functional> #include <sstream> #include <iostream> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstr...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<bits/stdc++.h> using namespace std; int main(){ string str; int n; cin >> n; while(n--){ cin >> str; int idx = 2; int cnt = 0; bool flg = true; if(str[0] == '>' && str[1] == 39){ bool used = false; while(idx < str.size() && str[idx] == '=') { used = true; cnt++; idx++;...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n; string s; int main(void) { cin >> n; for (int k = 0; k < n; k++) { cin >> s; bool f = true; if (s[0] == '>' && s[1] == '\'') { int c = 0; int i; for (i = 2; s[i] == '='; i++) c++; if (c && s[i] == '#') { for (i += 1; s[i] == '='; i++) ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<stdio.h> #include<string.h> int n,len; char t[300]; int checkA(){ if(t[len-1]!='~')return 0; int i=2,j=len-2; while(i<j){ if(t[i]!='=')return 0; if(t[j]!='=')return 0; i++; j--; } if(t[i]=='#')return 1; else return 0; } int checkB(){ if(t[len-2]!='~')return 0; if(t[len-1]...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
java
import java.io.*; import java.util.*; // 2011/10/23 // 0139 Snakes public class Main { // ƒƒCƒ“ return false‚Å‚¨‚µ‚Ü‚¢ boolean main() throws IOException { String s = reader.readLine(); String type = "NA"; String regA = ">'(=+)#(=+)\\~"; if (s.matches(regA)) { if (s.replaceAll(regA, "$1").eq...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
java
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String[] args) throws java.io.IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); String snake; bf.read...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <string> #include <iostream> using namespace std; int n; string s; int check() { if(s.size() < 6) return 0; if(s[0] != '>') return 0; if(s[1] == '\'') { int cnt = 0, cntp = 0; for(int i = 2; i < s.size() - 1; i++) { if(s[i] != '=') break; cnt++; cntp++; } if(s[2 + cnt] != '#') return 0; for(...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <stdio.h> bool checkA(char *p){ int eqCnt=0; if (*p++!='>') return false; if (*p++!='\'') return false; if (*p!='=') return false; while (*p++=='=') eqCnt++; p--; if (*p++!='#') return false; while (*p++=='=') eqCnt--; p--; if (eqCnt!=0) return false; if (*p++!...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <string> using namespace std; int main(){ int n; string s; cin >> n; for(int i = 0;i < n;i++){ cin >> s; if(s.substr(0,2) == ">\'"){ if(s[s.length() - 1] != '~') cout << "NA" << endl; else { int cnt = 0,pos = 2; bool flag = true; for(;;pos++){ if(s[pos] == '#...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; bool isA(string s) { int cnt1 = 0; for (int i = 2; i < s.size(); ++i) { if (s[i] == '=') { ++cnt1; } else if (s[i] == '#') { if (cnt1 == 0) return false; break; } else { return false; } if (i == s.size() - 1) return false; ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
python2
for i in range(input()): s = raw_input() l = (len(s) - 4) / 2 if l > 0 and s == ">'%s#%s~" % (('=' * l,) * 2): print('A') elif l > 0 and s == '>^%s~~' % ('Q=' * l): print('B') else: print('NA')
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
java
import java.util.Scanner; public class Main { public static void main(String arg[]) { Scanner in=new Scanner(System.in); int n=in.nextInt(); while(n-->0) { char ch[] = in.next().toCharArray(); int counta =0; int countb =0; boolean flag=false; if(ch[0]=='>'&&ch[1]=='\'' &&ch[ch.length-1]=='~'&&...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
java
import java.awt.geom.Point2D; import java.io.*; import java.math.BigInteger; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.List; im...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; public class Main { enum State{ START, MOUTH, EYE_A, EYE_B, BODY_A1, BODY_A2, BODY_B1, BODY_B2, MID_A, TAIL_A, TAIL_B1, TAIL_B2, NA; } String snake(String s){ State state=State.START; int ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0; i<(n); i++) struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star; bool check_A( string &S ) { auto sz = S.size(); //size ??? 6 ??\?????????????????? false if( sz < 6 ) { return 0; } //?????????[>'=], ??...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> using namespace std; /*s[i]ツつゥツづァツ督ッツつカツ閉カツ篠堋つェツ連ツ堕アツつオツづつ「ツづゥツ青板づーツ陛板つキ*/ int seqlen(string &s,int i){ char c = s[i]; int ret=0; while(s[i++]==c)ret++; return ret; } int main(){ int n; int flag = 0; string s; cin >> n; while(n--){ flag = 0; cin >> s; /*A*/ if(s[0]=='>' && s[1]==3...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
python3
import re n=int(input()) def A(snake): r=re.match("^>\'(\=+)\#(\=+)\~$",snake) if r: if len(r.group(1))==len(r.group(2)): return True return False def B(snake): r=re.match("^\>\^(Q=)+\~\~$",snake) if r: return True return False for i in range(n): S=input() ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #define VARIABLE(x) cerr << #x << "=" << x << endl #define rep(i,n) for(int i=0;i<(int)(n);i++) #define REP(i,m,n) for (int i=m;i<(int)(n);i++) const int INF = 10000000; using namespace std; typedef long long ll; /** Problem0139 : Snakes **/ int main() { int n; string s; cin >> n; rep(k, n) ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; string s; for (int i=0; i<n; ++i) { cin >> s; int m = s.size(); string res = "NA"; if (s.size() < 6 || s.size() % 2 == 1) { // pass } else if (s...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> #include<algorithm> #include<vector> #include<stack> #include<map> #include<set> #include<queue> #include<cstdio> #include<climits> #include<cmath> #include<cstring> #include<string> #include<sstream> #include<complex> #define f first #define s second #define mp make_pair #define REP(i,n) for(int i...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
python3
n=int(input()) for times in range(n): s=input() ans="NA" #A???????????§ if s[:2]==">'" and s[-1]=="~": t=s[2:-1].split("#") if len(t)==2 and len(t[0])>0: valid=True for v in t[0]: if v!="=": valid=False break if valid and t[0]==t[1]: ans="A" #B???????????§ elif s[:2]==">^" and s[...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<bits/stdc++.h> using namespace std; #define pb push_back #define fr first #define sc second typedef vector<int> vi; typedef pair<int,int> pii; typedef pair<int,pii> pip; const int INF = (1<<25); const int dx[]={1,0,-1,0},dy[]={0,-1,0,1}; int n, len; string s; int checkA() { int i=2, j=len-2; while(i<j)...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <string> using namespace std; void jagdeA( const string& str ) { int count = 0; int i; for( i = 2;i < str.size();i++ ){ if( str[i] == '=' ) count++; else if( count && str[i] == '#' ) break; else{ cout << "NA" << endl; return; } } if( i == str.size() ){ cout << "NA" ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> #include<string> using namespace std ; string S ; int funcA(){ int cnt = 0 , i ; for( i=2 ; i<S.size() ; i++ ){ if( S[i] == '=' ) cnt++ ; else if( S[i] == '#' ) break ; else return -1 ; } if( cnt == 0 ) return -1 ; for( i++ ; i<S.size() ; i++ ){ if( S[i] == '=' ) cnt-- ; else if( S[i...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
java
import java.io.*; import java.util.*; public class Main{ public static void main(String[] args){ try{ new Main(); }catch(IOException e){ e.printStackTrace(); } } public Main() throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); List<String> Ans = new Array...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <string> using namespace std; bool isA(const string& s){ if( s.size() >= 1 && s[0] != '>' ) return false; if( s.size() >= 2 && s[1] != '\'' ) return false; int cnt1 = 0, cnt2 = 0; for(int i=2, j=0 ; i < s.size()-1 ; i++ ){ if( s[i] == '=' ){ j? cnt1++ : cnt2++; }else if( s[i] ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <cstdio> #include <regex.h> #include <cstring> int main() { int n; regex_t regst[2]; regmatch_t match[3]; const char *pattern[] = {"^>'(=+)#(=+)~$", "^>\\^(Q=)+~~$"}; const char *type_label[] = {"A", "B", "NA"}; int type; char snake[201]; scanf("%d", &n); for (int x=0; x<n; x++) { sca...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<stdio.h> #include<string.h> bool checkA(char st[1001]){ int len = strlen(st); if(len<4)return false; if(st[len-1]!='~')return false; if(len%2 == 1)return false; st[len/2-1] = '='; for(int i = 0; i < len-1; i++){ if(st[i] !='=')return false; } return true; } bool checkB(char st[1001]){ if(strlen(s...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
java
import java.util.*; import java.lang.*; import java.io.*; class Main{ private static boolean snake_A(String snake) { if(snake.charAt(snake.length()-1) != '~') return false; if(snake.charAt(snake.length()-2) != '=') return false; if(!snake.substring(0,2).equals(">'")) return false; if(s...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <c...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> #include<string> using namespace std; int main(){ long n,f,i,j,k,m; string s; cin>>n; for(i=0;i<n;i++){ cin>>s; if(s.substr(0,2)==">'"){ if(s.substr(2,1)!="="){f=2;goto E;} j=s.find_first_not_of('=',3); m=j-2; if(s.substr(j,1)!="#"){f=2;goto E;} k=s.find_first_not_of('=',j+1); if(k-j-1!=m){f=2;goto E...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <string> #include <sstream> #include <algorithm> #include <vector> #include <utility> #include <stack> #include <queue> #include <map> #include <set> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #de...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while(n--) { string str; string kp; string set; int flag=0; int count=0; int count_b=0; int i=0; cin >> str; for(i=0;i<2;i++)kp+=str[i]++; if(kp==">'") { while(str[i]!='#') { if(str[i]=='=')count++; ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> #include<string> using namespace std; int main() { int n,f,i,m; string s; cin>>n; while(n-->0){ cin>>s; f=0; if(s[0]+s[1]=='>'+'\''){ m=s.find('#'); if(m!=string::npos){ for(i=1;s[m-i]==s[m+i];)i++; if(i>1 && m-i==1 && m+i==s.size()-1 && s[m+i]=='~')f=1; } ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#ifdef LOCAL #define _GLIBCXX_DEBUG #define __clock__ #else #pragma GCC optimize("Ofast") #endif #include<bits/stdc++.h> using namespace std; using ll = long long; using VI = vector<ll>; using VV = vector<VI>; using VS = vector<string>; using PII = pair<ll, ll>; // tourist set template <typename A, typenam...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
python3
#!/usr/bin/env python3 import re ans = ['A', 'B', 'NA'] for _ in range(int(input())): s = input() l = max([1, (len(s) - 4) // 2]) p = [r">'"+("="*l)+"#"+("="*l)+"~", r'>\^(Q=)+~~', r'\S'] for i in range(3): if re.match(p[i], s): print(ans[i]) break
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; while(T--) { string s; cin >> s; if(s[0]!='>'||s.size()<=3) cout << "NA" << endl; else if(s[1]=='\'') { if(s[s.size()-1]!='~'||s.size()%2) { cout << "NA" << endl; goto next; } s=s.substr(...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> #include<string> using namespace std; int main() { string s, r; int n,i; bool b; cin>>n; while(n--) { cin>>s; r = "NA"; if(s.size() > 5 && (s.size()&1)==0 && s[0]=='>') { if(s[1]=='\'') { if(s[s.size()-1]=='~' && s[s.size()/2]=='#') { b=true; for(i=2;i<s.size()/2...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> #include<string> #include<sstream> #include<cstdio> #include<cstring> #include<cmath> using namespace std; int main(){ int n; cin>>n; for(int i=0;i<n;++i){ string line; cin>>line; string sol = "NA"; if(line.find('#')!=string::npos){ bool flag = false; string a = ""; string b = ""...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <algorithm> #include <string> using namespace std; int main() { int Tc; string s; while(cin>>Tc) { while(Tc--) { cin >> s; int const N = s.size(); bool NA = 0; bool isA; if(s[0] != '>') NA = 1; if(s[1] == '\'') { if(s[2] != '=') NA = 1; for(int...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> #include<cstring> #include<algorithm> #include<string> #include<vector> #include<cstdio> #include<cmath> #define pb(in,tmp) in.push_back(tmp) #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,b) loop(i,0,b) #define all(in) in.begin(),in.end() const double PI=acos(-1); using namespace std; int ma...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; #define int long long #define FR first #define SC second #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++) #define each(a, b) fo...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; #define loop(i,a,b) for(int i=(a);i<ull(b);++i) #define rep(i,n) loop(i,0,n) #define all(a) (a).begin(), (a).end() const double eps = 1e-10; const double pi = acos(-1.0); const double inf = (int)1e8; int main(){ int n; cin >> n; rep(q,...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
java
import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static final int BIG_NUM = 2000000000; public static final int MOD = 1000000007; public static final long HUGE_NUM = 99999999999999999L; public static final double EPS = 0.000000001; @SuppressWar...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <string> using namespace std; int main(){ int n; cin >> n; for(int q=0;q<n;q++) { string str; cin >> str; if(str[0] != '>') { cout <<"NA"<<endl; continue; } else if(str[1] != '\''&& str[1] != '^') { cout << "NA" << endl; continue; } ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> #include<string> using namespace std; int check(string str) { if(str[0] != '>'){ return -1; } if(str[1] != '\'' && str[1] != '^'){ return -1; } if(str[2] == '='){ if(str[str.size()-1] != '~' || str[str.size()-2] != '='){ return -1; } int i=3,cnt1=1,cnt2=0; while(str[i] != '#'){ ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> #include<string> using namespace std; int isfa(string); int isfb(string); int main(){ int n,fa,fb; string str; cin >> n; for(int i = 0;i < n;i++){ cin >> str; if(str.size()>5){ fa = isfa(str); fb = isfb(str); }else fa=fb=0; if(fa == 1) cout << "A" << end...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
java
import java.util.*; import java.util.regex.*; import static java.lang.Math.*; import static java.lang.System.out; // AOJ public class Main { Scanner sc = new Scanner(System.in); public static void main(String[] args) { new Main().AOJ0139(); } void AOJ0145(){ int n=sc.nextInt(); } void AOJ0141(){ int ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <cstdio> #include <algorithm> #include <cmath> using namespace std; bool check_A(string str){ if(str.size() < 6 || str.size() % 2 == 1){ return false; } if(str.substr(0, 2) != ">'"){ return false; } int count = 0; for(int i = 2; i < (str.size() - 4) / 2 + 2; i++){ if(str[i] !=...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
python3
for _ in [0]*int(input()): s=input() if s[:2]==">'" and s[-1]=='~' and '#' in s: s=s[2:-1].split('#') print(['NA','A'][set(s[0])==set(s[1])=={'='} and len(set(s))==1]) elif s[:2]=='>^' and s[-2:]=='~~': s=s[2:-2] print(['NA','B'][len(s)==2*s.count('Q=') and len(s)>0]) els...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
java
import java.util.Scanner; class Main { public static void main(String args[]){ Scanner scan = new Scanner(System.in); int n = scan.nextInt(); Snake s; for(int i=0;i<n;i++){ s = new Snake(scan.next()); System.out.println(s.getType()); } } } class Snake{ String snake; Snake(String str){ snake...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> using namespace std; typedef string::iterator S; string ss; string snakeA(S it){ int count = 0; for(;it!=ss.end()&&*it=='=';it++,count++); if(!count) return "NA"; if(it==ss.end()||*it!='#') return "NA"; it++; for(;it!=ss.end()&&*it=='=';it++,count--); if(it==ss.end()||*...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <cstdio> #include <string.h> using namespace std; int checksnake(string, int); int main(void) { int n, len; char snake[200]; int type; cin >> n; for(int i = 0 ; i < n ; i++) { scanf("%s", snake); len = strlen(snake); type = checksnake(snake, len); if(type == 1) co...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <string> using namespace std; bool isa(string s) { int pos = 2,cnt = 0; if(s[pos] != '=') return false; while(s[pos] == '=') pos++,cnt++; if(s[pos] != '#') return false; pos++; for(int i=0; i<cnt; ++i) { if(s[pos+i] != '=') return false; } pos += cn...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
java
import java.util.*; class Main{ public static void main(String args[]){ Scanner s=new Scanner(System.in); int a=s.nextInt(); for(int i=0;i<a;i++){ String str=s.next(); boolean A=true; boolean B=true; if(str.charAt(0)!='>')A=B=false; if(str.length()<6||str.length()%2==1)A=B=false; if(str.length(...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> using namespace std; int main() { int n; for(cin>>n;n--;) { string s; cin>>s; string ans="NA"; if(s.substr(0,2)==">'" &&s[s.size()-1]=='~') { string tmp=s.substr(2,s.size()-3); // cout<<tmp<<endl; if(tmp.size()%2!=0 && tmp.size()>1 && tm...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> #include<string> #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,a) loop(i,0,a) using namespace std; bool asnake(string s){ int n=s.size(); if(n%2 || n<6)return false; string com=">\'"; rep(i,(n-4)/2)com+='='; com+='#'; rep(i,(n-4)/2)com+='='; com+='~'; if(s==com)return true; else re...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
java
import static java.util.Arrays.deepToString; import java.util.Arrays; import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String[] args) { new Main().run(); } void tr(Object... os) { System.err.println(deepToString(os)); } Sca...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <string> using namespace std; int main(void){ int i,j,n,a; string s,ans; cin >> n; for(i = 0 ; i < n ; i++ ){ cin >> s; ans = "NA"; if( s[0] == '>'){ if( s[1] == '\''){ a = 2; int cnt1 = 0,cnt2 = 0; if( s[a] == '='){ while( s[a] == '='){ ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
java
import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); Pattern a = Pattern.compile(">'(=+)#\\1~"); Pattern b = Pattern.compile(">\\^(Q=)+~~"); ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <cstdio> #include <cstdlib> #include <queue> #include <stack> #include <vector> #include <algorithm> #include <string> #include <cstring> #include <cmath> #include <complex> #include <map> #include <climits> #include <sstream> using namespace std; #define reep(i,a,b) for(int i=(a);i<(b);++...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<cassert> #include<iostream> #include<sstream> #include<string> #include<vector> #include<queue> #include<set> #include<map> #include<utility> #include<numeric> #include<algorithm> #include<bitset> #include<complex> using namespace std; type...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
python3
def checkA(s): if s[:2] == ">'" and s[-1] == "~": body = s[2:-1] if len(body) >= 3 and body.count("#") == 1 and body.index("#") == len(body) // 2 and body.count("=") == len(body) - 1: return True else: return False else: return False def checkB(s): if s[:2] == ">^" and s[-2:] == "~~":...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
java
import java.util.Scanner; //Snakes public class Main{ static boolean isA(char[] s){ if(s.length<6)return false; if(!(s[0]=='>'&&s[1]=='\''))return false; int con = 0; while(2+con<s.length && s[2+con]=='=')con++; if(con==0)return false; if(2+con==s.length||s[2+con]!='#')return false; int b = 3+con; in...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> using namespace std; bool chk_a(const string s) { bool c = true; int f, b; f = b = 0; for (int i = 0; i < s.size(); i++) { if (s[i] != '=' && s[i] != '#') return false; if (c && s[i] == '#') c = false; else if (s[i] == '=' && c) ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <string> using namespace std; int main() { const string Type[] = {"A", "B", "NA"}; int n; while (cin >> n) { for (int i = 0; i < n; ++i) { string snake; cin >> snake; int ans = 2; int length = static_cast<int>(snake.size()); if (snake[0] == '>' && ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
java
//package _0139; import java.util.*; import java.lang.*; import java.math.*; public class Main { Scanner sc = new Scanner(System.in); boolean isA(String snake) throws Exception { if (snake.startsWith(">'")) { if (snake.endsWith("~")) { String mid = snake.substring(2, snake.length() - 1); ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
python3
n = int(input()) for i in range(n): s = input() if s[:2] == ">'" and s[-1] == '~' and len(s) % 2 == 0 and '=#=' in s: temp = ">'" + '=' * (s.count('=')//2) + '#' + '=' * (s.count('=')//2) + '~' if s == temp: print('A') continue elif s[:2] == ">^" and s[-2:] == '~~' an...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; public class Main { enum State{ START, MOUTH, EYE_A, EYE_B, BODY_A1, BODY_A2, BODY_B1, BODY_B2, MID_A, TAIL_A, TAIL_B1, TAIL_B2, NA; } String snake(String s){ State state=State.START; int ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
python2
def A(): p = s[2:] count = 0 index = 0 for i, c in enumerate(p): if c == '=': count += 1 elif c == '#': index = i break else: print 'NA' return else: if not index: print 'NA' return ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <algorithm> #include <string> using namespace std; string kaga(string s,int num){ string san; for(int i=0;i<num;i++)san+=s; return san; } void check(string s){ for(int i=1;i<99;i++){ string a,b; a=">'"+kaga("=",i)+'#'+kaga("=",i)+'~'; b=">^"+kaga("Q=",i)+"~~"; if(a==s){ cou...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> //”CˆÓ•¶Žš‚ðÁ‚·ŠÖ” int clear(std::string s, std::string f){ int pos; while(pos = s.find(f), pos != std::string::npos) s.replace(pos,f.size(),""); if(s == "")return 1; return 0; } int main(){ int n; std::cin >> n; while(n--){ std::string sn, res = ""; std::cin >> sn; //Type A //...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0; i<(n); i++) #define REP2(i,x,n) for(int i=x; i<(n); i++) #define ALL(n) begin(n),end(n) struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star; int check( string S ) { //A if( S[ 0 ] == '>' && S[ 1 ] == '\'' && S[ S.size() - 1 ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> #include<string> using namespace std; int main() { int n,i,j; string str; cin >> n; for(i=0;i<n;i++) { cin >> str; if(str[0]=='>') { if(str[1]=='\'') { int num=0; for(j=2;j<str.size();j++) { if(str[j]=='=') num++; else if(num>0 && str[j]=='#') ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> #include<string> using namespace std; int main(){ int n,j,fa,fb,acount,acount2,i; string data; cin >> n; getline(cin,data); for(j = 0; j < n; j++){ fa = 0; fb = 0; acount = acount2 = 0; getline(cin,data); if(data.length() < 6) data = "OOHAZURE"; if(data[...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
//11 #include<string> #include<iostream> using namespace std; int main(){ int n; cin>>n; while(n--){ string s; cin>>s; if(s.size()>=6&&s==">'"+string((s.size()-4)/2,'=')+'#'+string((s.size()-4)/2,'=')+'~'){ cout<<'A'<<endl; }else{ int r=(s.size()-4)/2; string b; while(r--...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> #include<string> using namespace std; bool isA(string s){ if(s.size() < 6 || s.size() % 2 == 1) return false; if(s.substr(0,2) != ">\'") return false; if(s[s.size() - 1] != '~') return false; int a, b; for( a = 2, b = s.size() - 2 ; a != b ; a++, b--){ if(s[a] != '=' || s[b] != '=') ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
java
import java.util.*; import java.io.*; public class Main { public String species(String snake){ if( snake.length() < 5 || snake.charAt(0) != '>' || snake.charAt(snake.length()-1) != '~' ){ return "NA"; } if( snake.charAt(1) == '\'' ){ int count = 0; boolean flag = true; for(int i = 2; i < snake.len...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <stdio.h> #include <iostream> #include <algorithm> #include <iomanip> #include <map> #include <fstream> #include <sstream> #include <math.h> #include <queue> #include <stack> #include <math.h> #include <string.h> using namespace std; bool hebi_a(string hebi){ if(!(hebi[0]=='>' && hebi[1]=='\''))return ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
# define _CRT_SECURE_NO_WARNINGS 1 # include <iostream> # include <numeric> # include <string> # include <bitset> # include <vector> # include <algorithm> # include <cstdlib> # include <cstdio> # include <cstring> # include <cstdlib> # include <iomanip> # include <queue> # include <sstream> # include <climits> # includ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <vector> #include <algorithm> #include <numeric> #include <set> #include <map> #include <string> #include <stack> #include <queue> #include <cmath> #include <cstdio> #include <istream> #include <sstream> #include <iomanip> #include <iterator> #include <climits> using namespace std; typedef...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> #include<string> using namespace std; int main(){ int f,i,m; string s; for(cin>>f;cin>>s;f?puts(f-2?"A":"B"):puts("NA")){ f=0; for(i=1;s[0]+s[1]==101 & (m=s.find(35))!=string::npos & s[m-i]==s[m+i];) m-++i-1 | m+i-s.size()+1 | s[m+i]-'~'||(f=1); for(i=2;s[0]+s[1]==156 & s[i]=...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <complex> #include <cstring> #include <cstdlib> using namespace std; #define REP(i,n) for(int i=0;i<(int)n;++i) #define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i) #define ALL(c) (c).begin(), (c).end() int main...