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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
class Ex(Exception): pass n=int(input()) for i in range(n): try: snk=input() l=len(snk) head=snk[:2] body=snk[2:l-1] tail=snk[l-1] if tail!='~' or snk[0]!='>': print("NA") continue spl_a=body.split('#') if len(spl_a)==2 and spl_a[0]==spl_a[1]: for char in spl_a[0]: if char!='=': print("NA") raise Ex() if head[1]=='\'': print('A') raise Ex() else: print("NA") raise Ex() bars=body.split('=') for j in range(len(bars)-1): if bars[j]!='Q': print("NA") raise Ex() if head[1]=='^':print('B') else:print("NA") except Ex:pass
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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; const int MOD = 1e9 + 7; signed main() { int n; cin >> n; regex b(R"(>\^(Q=)+~~)"); for (int i = (0); i < (n); i++) { string s; cin >> s; int m = 0; for (int j = (0); j < (s.size()); j++) if (s[j] == '=') m++; regex a(">'={" + to_string(m / 2) + "}#={" + to_string(m / 2) + "}~"); if (regex_match(s, a)) { cout << "A" << endl; } else if (regex_match(s, b)) { cout << "B" << endl; } else cout << "NA" << endl; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while (n--) { string snake; cin >> snake; string s = snake.substr(0, 2); if (s != ">^" && s != ">\'") { puts("NA"); continue; } if (s == ">\'") { int a = 0; int p = 2; bool flg = true; int len = (int)snake.size(); for (int i = 2; i < len; i++, p++) { if (snake[i] == '#') break; else if (snake[i] == '=') a++; else { flg = false; break; } } if (!flg) { puts("NA"); continue; } int b = 0, q = p + 1; for (int i = q; i < len; i++, p++) { if (snake[i] == '~') break; else if (snake[i] == '=') b++; else { flg = false; break; } } if (!flg) { puts("NA"); continue; } if (a == b && snake[len - 1] == '~') { puts("A"); } else { puts("NA"); } } else { bool ok = true; int p = 0; string ss = ""; int len = (int)snake.size(); for (int i = 2; i < len - 2; i++, p++) { ss += snake[i]; if (p == 1) { p = -1; if (ss != "Q=") { ok = false; break; } ss = ""; } } if (snake[len - 2] == '~' && snake[len - 1] == '~' && ok) { puts("B"); } else { puts("NA"); } } } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { string s; int n; cin >> n; for (int i = 0; i < n; i++) { cin >> s; int size = s.size(); string A = ""; string B = ""; for (int i = 0; i < size; i++) { if (i == 0) { A += ">"; B += ">"; } else if (i == 1) { A += "'"; B += "^"; } else { if (i < size - 1) { if (i == (size - 3) / 2 + 2) A += "#"; else A += "="; } else A += "~"; if (i < size - 2) { if (i % 2 == 0) B += "Q"; else B += "="; } else { B += "~"; } } } if (size % 2 == 0) { if (s == A) cout << "A" << endl; else if (s == B) cout << "B" << endl; else cout << "NA" << endl; } else cout << "NA" << endl; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; struct cww { cww() { ios::sync_with_stdio(false); cin.tie(0); } } star; int check(string S) { if (S[0] != '>' || S[S.size() - 1] != '~') { return 0; } if (S[1] == '\'') { if (S.substr(2, S.size() - 3).find_first_not_of("#=", 0) != string::npos) return 0; string tmpB = S.substr(2, S.find('#') - 2); string tmpA = S.substr(S.find('#') + 1, S.size() - (S.find('#') + 2)); return tmpB.size() == tmpA.size() ? 1 : 0; } if (S[1] == '^' && S[S.size() - 2] == '~') { if (S.substr(2, S.size() - 4).find_first_not_of("Q=", 0) != string::npos) return 0; for (int i = 2; i < S.size() - 2; i += 2) { if (S[i] != 'Q' && S[i + i] != '=') return 0; } return 2; } } int main() { int N; cin >> N; vector<string> res{"NA", "A", "B"}; string S; while (cin >> S) { cout << res[check(S)] << endl; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <iostream> #include <cstdio> #include <algorithm> #include <cassert> #include <vector> #include <string> #include <cmath> #include <map> #include <sstream> #include <cstdio> #include <complex> #include <cstring> using namespace std; const int MAX= 10000100; #define loop(i,a,b) for(int i = a ; i < b ; i ++) #define rep(i,a) loop(i,0,a) #define all(a) (a).begin(),(a).end() #define ll long long int #define gcd(a,b) __gcd(a,b) #define pb(a) push_back(a) int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);} int lcm(int a, int b) {return a*b / gcd(a, b);} bool A(string s){ if(s.size()%2 != 0)return false; if(s[0] != '>')return false; if(s[1] != '\'')return false; if(s[s.size()-1] != '~')return false; if(s[s.size()/2] != '#')return false; else s[s.size()/2] = '='; loop(i,2,s.size()-1){ if(s[i] != '=')return false; } return true; } bool B(string s){ if(s[0] != '>')return false; if(s[1] != '^')return false; loop(i,2,s.size()-2){ if(i%2){ if(s[i] != '=')return false; }else{ if(s[i] != 'Q')return false; } } if(s[s.size()-2] != '~')return false; if(s[s.size()-1] != '~')return false; return true; } int main(void){ int n; cin>>n; rep(i,n){ string s; cin>>s; if(A(s))cout<<"A"; else if(B(s))cout<<"B"; else cout<<"NA"; cout<<endl; } }
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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <iostream> #include <string> using namespace std; int main() { int n; cin >> n; for(int i = 0; i < n; i++) { string s; cin >> s; bool a[4] = {}, b[3] = {}; int cnt = 0; for(int j = 0; j < s.size(); j++) { if(s[j] == '>') { if(!a[1] && s[j+1] == ''') a[0] = true; if(s[j+1] == '^') b[0] = true; } else if(a[0] && s[j] == '=') { a[1] = true; cnt++; } else if(b[0] && s.substr(j,2) == "Q=") { b[1] = true; } else if(a[1] && s[j] == '#') { a[0] = false; a[2] = true; } else if(a[2] && s[j] == '=') { cnt--; } else if(a[1] && cnt == 0 && j+1 == s.size() && s[j] == '~') { a[3] = true; } else if(b[1] && j+2 == s.size() && s.substr(j,2) == "~~") { b[2] = true; } } if(a[3]) cout << 'A' << endl; else if(b[2]) cout << 'B' << endl; else cout << "NA" << endl; } }
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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int SnakeIsA(const char* str) { int eq_cnt = 0; if (strncmp(str, ">'", 2) != 0) return 0; str += 2; while (1) { if (*str != '=') return 0; eq_cnt++; str++; if (*str == '#') break; } str++; while (1) { if (*str != '=' || eq_cnt == 0) return 0; eq_cnt--; str++; if (*str == '~') break; } return (eq_cnt == 0) ? 1 : 0; } int SnakeIsB(const char* str) { if (strncmp(str, ">^", 2) != 0) return 0; str += 2; while (1) { if (strncmp(str, "Q=", 2) != 0) return 0; if (strncmp(str, "~~", 2) != 0) break; str += 2; } return 1; } int main(void) { int i, n; char get[201]; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%s", get); if (SnakeIsA(get)) printf("A\n"); else if (SnakeIsB(get)) printf("B\n"); else printf("NA\n"); } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; struct cww { cww() { ios::sync_with_stdio(false); cin.tie(0); } } star; bool check_A(string &S) { auto sz = S.size(); if (sz < 6) { return 0; } if (!(S[0] == '>' && S[1] == '\'' && S[2] == '=' && S[sz - 1] == '~')) { return 0; } string R = S.substr(2, sz - 3); sz = R.size(); if (R.find_first_not_of("#=", 0) != string::npos) { return 0; } if (sz % 2 == 0) { return 0; } auto pos = R.find("#"); if (R.find("#", pos + 1) != string::npos) { return 0; } if (R[sz / 2] != '#') { return 0; } return 1; } bool check_B(string &S) { auto sz = S.size(); if (sz < 6) { return 0; } if (!(S[0] == '>' && S[1] == '^' && S[sz - 1] == '~' && S[sz - 2] == '~')) { return 0; } string R = S.substr(2, sz - 4); sz = R.size(); if (sz % 2 != 0) { return 0; } for (int i = 0; i < sz; i += 2) { if (R[i] != 'Q' && R[i + 1] != '=') { return 0; } } return 1; } int main() { int N; cin >> N; for (int i = 0; i < (N); i++) { string S; cin >> S; string res{"NA"}; if (check_A(S)) { res = "A"; } if (check_B(S)) { res = "B"; } cout << res << endl; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(void) { int n, len, flag = 0, flag2 = 0, cnt1 = 0, cnt2 = 0; char snake[10000][200]; cin >> n; for (int i = 0; i < n; i++) { scanf("%s", snake[i]); len = strlen(snake[i]); if (snake[i][0] == '>' && snake[i][1] == '\'') { for (int j = 2; j < len - 1; j++) { if (snake[i][j] == '=' && flag == 0) { cnt1++; flag2 = 1; } if (snake[i][j] == '=' && flag == 1) { cnt2++; flag2 = 1; } if (snake[i][j] == '#') flag = 1; } if (snake[i][len - 1] == '~' && cnt1 == cnt2 && flag2 == 1) cout << 'A' << endl; else cout << "NA" << endl; flag = 0; flag2 = 0; cnt1 = 0; cnt2 = 0; } else if (snake[i][0] == '>' && snake[i][1] == '^') { for (int j = 2; j < len - 2; j++) { if (snake[i][j] == 'Q' && snake[i][j + 1] == '=') flag = 1; } if (snake[i][len - 2] == '~' && snake[i][len - 1] == '~' && flag == 1) { cout << 'B' << endl; flag = 0; } else cout << "NA" << endl; } else cout << "NA" << endl; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); while (n-- > 0) { String snake = sc.next(); if (snake.indexOf('#') > 0 && snake.charAt(0) == '>' && snake.charAt(1) == '\'' && snake.charAt(snake.length() - 1) == '~') { int count=0; for(int i=2,j=snake.length()/2+1;i<snake.length()/2;i++,j++) { if(snake.charAt(i)=='='&&snake.charAt(j)=='=') { count+=2; } } if(count==snake.length()-4) { System.out.println("A"); }else { System.out.println("NA"); } } else if (snake.charAt(0) == '>' && snake.charAt(1) == '^' && snake.charAt(snake.length() - 2) == '~' && snake.charAt(snake.length() - 1) == '~' && snake.replaceAll("Q=", "").equals(">^~~")) { System.out.println("B"); } else { System.out.println("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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> char s[201]; int A(int p, int st, int c) { if (st == 2 && c == 0 && s[p] == 0) return 1; else if (st == 1 && s[p] == '~') return A(p + 1, st + 1, c); else if (st == 1 && s[p] == '=') return A(p + 1, st, c - 1); else if (st == 0 && s[p] == '#') return A(p + 1, st + 1, c); else if (st == 0 && s[p] == '=') return A(p + 1, st, c + 1); else return 0; } int B(int p, int st) { if (st == 3 && s[p] == 0) return 1; else if ((st == 1 || st == 2) && s[p] == '~') return B(p + 1, st + 1); else if (st == 0 && s[p] == '=') return B(p + 1, 1); else if (st == 1 && s[p] == 'Q') return B(p + 1, 0); else return 0; } int main() { int n, i; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%s", s); if (s[0] == '>' && s[1] == '\'' && A(2, 0, 0)) puts("A"); else if (s[0] == '>' && s[1] == '^' && B(2, 1)) puts("B"); else puts("NA"); } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int A_snake(char snake[]); int B_snake(char snake[]); int main(void) { int quantity, i; char snake[201] = {0}; scanf("%d", &quantity); for (i = 0; i < quantity; i++) { scanf("%s", snake); if (snake[0] != '>') { puts("NA"); } else if (snake[1] == '\'') { if (A_snake(snake)) { puts("A"); } else { puts("NA"); } } else if (snake[1] == '^') { if (B_snake(snake)) { puts("B"); } else { puts("NA"); } } else { puts("NA"); } } return (0); } int A_snake(char snake[]) { int j, idx = 0, count = 0; for (j = 2; j < 201; j++) { if (snake[j] != '=' && snake[j] != '#') if (snake[j] != '~') return (0); if (snake[j] == '=') { count++; } else if (snake[j] == '#') { idx = j; break; } } for (j = idx + 1; j < 201; j++) { if (snake[j] == '=') { count--; } else if (snake[j] != '=') { idx = j; break; } } if (count == 0) { if (snake[idx] == '~' && snake[idx + 1] == '\0') return (1); else return (0); } else { return (0); } } int B_snake(char snake[]) { int j, idx, count = 0; char *str; str = &snake[2]; for (j = 2; j < 201; j += 2) { if (strncmp(str, "Q=", 2) != 0 && strncmp(str, "~~", 2) != 0) count++; if (!(strncmp(str, "~~", 2))) { idx = j; break; } str += 2; } if (count == 0 && (snake[idx] == '~' && snake[idx + 1] == '~')) { if (snake[idx + 2] == '\0') { return (1); } else { return (0); } } else return (0); 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> 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] == '#') { j++; } else { return false; } } if (cnt1 == 0 || cnt2 == 0 || cnt1 != cnt2 || s[s.size() - 1] != '~') { return false; } return true; } bool isB(const string& s) { if (s.size() >= 1 && s[0] != '>') return false; if (s.size() >= 1 && s[1] != '^') return false; if (s.size() <= 6 || s.size() % 2 == 1) return false; bool flag = false; for (int i = 3; i < s.size() - 2; i += 2) { if (s[i - 1] != 'Q' || s[i] != '=') { return false; } } if (s[s.size() - 2] != '~' || s[s.size() - 1] != '~') { return false; } return true; } int main() { int n; cin >> n; for (; n--;) { string s; cin >> s; if (isA(s)) { cout << "A" << endl; } else if (isB(s)) { cout << "B" << endl; } else { cout << "NA" << endl; } } }
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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; bool isa(string s) { int pos = 2; while (s[pos] == '=') pos++; if (pos == 2 || s[pos] != '#') return false; int cnt = pos++ - 2; for (int i = 0; i < cnt; ++i) { if (s[pos + i] != '=') return false; } pos += cnt; if (pos == s.length() - 1 && s[pos] == '~') return true; return false; } bool isb(string s) { int pos = 2; for (; pos < s.length() - 2; pos += 2) if (s[pos] != 'Q' || s[pos + 1] != '=') return false; if (s[s.length() - 1] == s[s.length() - 2] && s[s.length() - 1] == '~') return true; return false; } int main() { int n; cin >> n; string s; for (int i = 0; i < n; ++i) { cin >> s; if (s[1] == '\'') { if (isa(s)) { cout << "A" << endl; } else { cout << "NA" << endl; } } else { if (isb(s)) { cout << "B" << endl; } else { cout << "NA" << endl; } } } }
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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; struct cww { cww() { ios::sync_with_stdio(false); cin.tie(0); } } star; int check(string S) { if (S[0] != '>' || S[S.size() - 1] != '~') { return 0; } if (S[1] == '\'') { S = S.substr(2, S.size() - 3); if (S.find_first_not_of("#=", 0) != string::npos) return 0; string tmpB = S.substr(0, S.find('#')); string tmpA = S.substr(S.find('#') + 1, S.size() - 1); return tmpB.size() == tmpA.size() ? 1 : 0; } if (S[1] == '^' && S[S.size() - 2] == '~') { S = S.substr(2, S.size() - 4); if (S.find_first_not_of("Q=", 0) != string::npos) return 0; for (int i = 0; i < S.size(); i += 2) { if (S[i] != 'Q' && S[i + 1] != '=') return 0; } return 2; } } int main() { int N; cin >> N; vector<string> res{"NA", "A", "B"}; string S; while (cin >> S) { cout << res[check(S)] << endl; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; while (N--) { string s; cin >> s; if (s[0] != '>') { cout << "NA" << endl; continue; } int select = 0; if (s[1] == '\'') { int cnt = 0; if (!(s.size() % 2)) { for (int i = 2; i < s.size() / 2; i++) { if (s[i] != '=') { select = -1; break; } cnt++; } for (int i = s.size() / 2 + 1; i < s.size() - 1; i++) { if (s[i] != '=') { select = -1; break; } cnt--; } } else select = -1; if (!cnt && ~select && s[s.size() / 2] == '#' && s[s.size() - 1] == '~') cout << "A" << endl; else cout << "NA" << endl; } else if (s[1] == '^') { if (!(s.size() % 2)) { for (int i = 2; i < s.size() - 2; i++) { if ((!(i % 2) && s[i] != 'Q') || (i % 2 && s[i] != '=')) { select = -1; break; } } if (~select && s[s.size() - 1] == s[s.size() - 2] && s[s.size() - 1] == '~') cout << "B" << endl; else cout << "NA" << endl; } else cout << "NA" << endl; } else { cout << "NA" << endl; } } }
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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; struct cww { cww() { ios::sync_with_stdio(false); cin.tie(0); } } star; bool check_A(string S) { auto sz = S.size(); if (S.find(">'") == 0 && S.find("~") == sz - 1 && sz >= 6) { S = S.substr(2, sz - 3); sz = S.size(); if (S.find_first_not_of("#=", 0) != string::npos) { return 0; } auto pos = S.find("#"); if (S.find("#", pos + 1) != string::npos) { return 0; } return S[sz / 2] == '#' ? 1 : 0; } return 0; } bool check_B(string S) { auto sz = S.size(); if (S.find(">^") == 0 && S.find("~~") == sz - 2 && sz >= 6) { S = S.substr(2, sz - 4); sz = S.size(); if (sz % 2 != 0) { return 0; } for (int i = 0; i < sz; i += 2) { if (S[i] != 'Q' && S[i + 1] != '=') { return 0; } } return 1; } return 0; } int main() { int N; cin >> N; for (int i = 0; i < (N); i++) { string S; cin >> S; if (check_A(S)) { cout << "A" << endl; } else if (check_B(S)) { cout << "B" << endl; } else { cout << "NA" << endl; } } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; getchar(); for (int i = 0; i < n; i++) { string snake; getline(cin, snake); string ans = "NA"; if (snake[0] == '>' && snake[1] == '\'') { int shape = 0; for (int i = 2; i < snake.length(); i++) { if (i + 1 >= snake.length()) { if (snake[i] == '~') ans = "A"; } else { if (snake[i] != '=' && snake[i] != '#') break; if (snake[i] == '#') { if (shape == 1) break; else { shape++; if (i - 2 != (double)(snake.length() - 4) / 2) break; } } } } } else if (snake[0] == '>' && snake[1] == '^') { for (int i = 3; i < snake.length(); i += 2) { if (i + 2 >= snake.length()) { if (snake[i - 1] == '~' && snake[i] == '~') ans = "B"; } else { if (snake[i - 1] != 'Q' || snake[i] != '=') break; } } } cout << ans << endl; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> 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] == '#') { for (j += 1; j < str.size(); j++) { if (j == str.size() - 1 && str[j] == '~' && num == 0) cout << "A" << endl; else if (j != str.size() - 1 && str[j] == '=') num--; else { cout << "NA" << endl; break; } } break; } else { cout << "NA" << endl; break; } } } else if (str[1] == '^') { for (j = 2; j < str.size(); j++) { if (j == str.size() - 2 && str[j] == '~' && str[j + 1] == '~') { cout << "B" << endl; break; } else if (j == str.size() - 2 && (str[j] != '~' || str[j + 1] != '~')) { cout << "NA" << endl; break; } else if ((j % 2 == 0 && str[j] != 'Q') || (j % 2 == 1 && str[j] != '=')) { cout << "NA" << endl; break; } } } } else cout << "NA" << endl; } }
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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; struct cww { cww() { ios::sync_with_stdio(false); cin.tie(0); } } star; bool check_A(string &S) { auto sz = S.size(); if (S.find(">'=") != 0 || S.find("~") != sz - 1 || sz < 6) { return 0; } string R = S.substr(2, sz - 3); sz = R.size(); if (R.find_first_not_of("#=", 0) != string::npos) { return 0; } if (sz % 2 == 0) { return 0; } auto pos = R.find("#"); if (R.find("#", pos + 1) != string::npos) { return 0; } if (R[sz / 2] != '#') { return 0; } return 1; } bool check_B(string &S) { auto sz = S.size(); if (S.find(">^Q=") != 0 || S.find("~~") != sz - 2 || sz < 6) { return 0; } string R = S.substr(2, sz - 4); sz = R.size(); if (sz % 2 != 0) { return 0; } for (int i = 0; i < sz; i += 2) { if (R[i] != 'Q' && R[i + 1] != '=') { return 0; } } return 1; } int main() { int N; cin >> N; for (int i = 0; i < (N); i++) { string S; cin >> S; string res{"NA"}; if (check_A(S)) { res = "A"; } if (check_B(S)) { res = "B"; } cout << res << endl; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main(void) { int max, data; int num; int cut_i; char hebi[] = "\0"; scanf("%d", &max); for (data = 0; data < max; data++) { scanf("%s", hebi); if (strlen(hebi) < 2 || hebi[0] != '>') { puts("NA"); continue; } if (hebi[1] == '\'') { num = 0; cut_i = 2; while (hebi[cut_i] == '=') { cut_i++; num++; } if (hebi[cut_i] != '#' || num <= 0) { puts("NA"); } else { cut_i++; while (hebi[cut_i] == '=') { cut_i++; num--; } if (num != 0) { puts("NA"); } else if (hebi[cut_i] != '~' || hebi[cut_i + 1] != 0) { puts("NA"); } else { puts("A"); } } } else if (hebi[1] == '^') { cut_i = 2; while (hebi[cut_i] == 'Q' && hebi[cut_i + 1] == '=') { cut_i += 2; } if (cut_i == 2) { puts("NA"); } else if (hebi[cut_i] != '~' || hebi[cut_i + 1] != '~' || hebi[cut_i + 2] != 0) { puts("NA"); } else { puts("B"); } } else { puts("NA"); } } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> extern int is_SNAKEA_body(char *s, int len); extern int is_SNAKEB_body(char *s, int len); int is_SNAKEA_body(char *s, int len) { if (len == 0) return (-0); else if (len == 1 && s[0] == '#') return (-1); else if (s[0] == '=' && s[len - 1] == '=') return (is_SNAKEA_body(s + 1, len - 2)); else return (0); } int is_SNAKEA(char *s) { int len = strlen(s); if (0 == strncmp(">'", s, 2) && is_SNAKEA_body(s + 2, len - 3) && s[len - 1] == '~') return (-1); else return (0); } int is_SNAKEB_body(char *s, int len) { if (len == 0 || len & 1) return (-0); else if (len == 2 && 0 == strncmp("Q=", s, 2)) return (-1); else if (0 == strncmp("Q=", s, 2)) return (is_SNAKEB_body(s + 2, len - 2)); else return (0); } int is_SNAKEB(char *s) { int len = strlen(s); if (0 == strncmp(">^", s, 2) && is_SNAKEB_body(s + 2, len - 4) && s[len - 2] == '~' && s[len - 1] == '~') return (-1); else return (0); } int main() { int i; char snake[201]; int cnt; scanf("%d", &cnt); for (i = 0; i < cnt; i++) { scanf("%s", snake); if (is_SNAKEB(snake)) printf("B\n"); else if (is_SNAKEA(snake)) printf("A\n"); else printf("NA\n"); } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int i, n; string s; cin >> n; while (n--) { cin >> s; if (s[0] == '>' && s[1] == '\'') { for (i = 2; i < s.size(); i++) { if (i == s.size() / 2 && s[i] != '#') break; if (i == s.size() / 2) { i++; continue; } if (i == s.size() - 1 && s[i] == '~') { cout << "A" << endl; goto L; } if (s[i] != '=') break; } } else if (s[0] == '>' && s[1] == '^') { for (i = 2; i < s.size(); i++) { if (i == s.size() - 2 && s[i] == '~' && s[i + 1] == '~') { cout << "B" << endl; goto L; } if (s[i] != 'Q' || s[i + 1] != '=') break; else i++; } } cout << "NA" << endl; L:; } }
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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int i, count; string s, name; getline(cin, s); while (getline(cin, s)) { if (s[1] == '\'') { name = "A"; if (s[2] != '=') name = "NA"; else { count = 0; for (i = 2; s[i] == '='; i++) count++; if (s[i] != '#') name = "NA"; else { for (; count > 0; count--) if (s[++i] != '=') { name = "NA"; break; } if (s[++i] != '~' || i != s.size() - 1) name = "NA"; } } } else if (s[1] == '^') { name = "B"; for (i = 2; i < s.size(); i += 2) { if (s.size() & 1) { name = "NA"; break; } if (s[i] != 'Q' || s[i + 1] != '=') { if (s[i] != '~' || s[i + 1] != '~' || i + 1 != s.size() - 1) name = "NA"; break; } } } cout << name << endl; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main(void) { int n, i, c1, c2, f; char s[201]; scanf("%d", &n); while (n--) { scanf("%s", s); f = 0; if (s[0] != '>') { puts("NA"); continue; } if (s[1] == '\'') { c1 = c2 = 0; for (i = 2; s[i] != '#'; i++) { if (s[i] != '=') { break; } c1++; } for (i++; s[i] != '~'; i++) { if (s[i] != '=') { break; } c2++; } if (c1 == c2 && s[i + 1] == '\0') { f = 1; } if (f) { puts("A"); } else { puts("NA"); } } else if (s[1] == '^') { for (i = 2; s[i] != '~'; i = i + 2) { if (!(s[i] == 'Q' && s[i + 1] == '=')) { break; } } if (s[i] == '~' && s[i + 1] == '~' && s[i + 2] == 0) { f = 1; } if (f) { puts("B"); } else { puts("NA"); } } else { puts("NA"); } } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main(int argc, const char* argv[]) { int num; int i, j, k, l; scanf("%d", &num); for (l = 0; l < num + 1; l++) { char snake[200]; int bodyacnt = 0; int bodybcnt = 0; int midcnt = 0; int endacnt = 0; int endbcnt = 0; int nacnt = 0; for (i = 0; i < 200; i++) { scanf("%c", &snake[i]); if (snake[i] == '\n') { break; } } if (snake[0] == '>') { if (snake[1] == '\'') { for (j = 2; j < i; j++) { if (snake[j] == '=') { bodyacnt++; } else if (snake[j] == '#') { break; } } for (k = j; k < i; k++) { if (snake[k] == '=') { midcnt++; } else if (snake[k] == '~') { endacnt++; if (endacnt == 1) { break; } } } } else if (snake[1] == '^') { for (j = 2; j < i / 2; j += 2) { if (snake[j] == 'Q' && snake[j + 1] == '=') { bodybcnt++; } else nacnt++; } if (snake[i - 2] == '~' && snake[i - 1] == '~') { endbcnt++; } } else nacnt++; } if (bodybcnt > 0 && endbcnt == 1 && nacnt == 0) { printf("B\n"); } else if (bodyacnt == midcnt && endacnt == 1 && nacnt == 0 && bodyacnt > 0) { printf("A\n"); } else if (l != 0) printf("NA\n"); } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; public class Main { /** * @param args */ int solve(String str) { final int HEAD=0; final int EYE_A=1; final int EYE_B=2; final int BODY_A1=3; final int BODY_A2=4; final int BODY_B=5; final int STOMACH_A=6; final int TAIL_A=7; final int TAIL_B=8; int state=-1; int count=0; for(int i=0;i<str.length();++i) { switch(str.charAt(i)) { case '>': if(state==-1){state=HEAD;} else{return 2;} break; case '\'': if(state==HEAD){state=EYE_A;} else{return 2;} break; case '^': if(state==HEAD){state=EYE_B;} else{return 2;} break; case 'Q': if(state==EYE_B){state=BODY_B;} if(state!=BODY_B||++i>=str.length()||str.charAt(i)!='='){return 2;} break; case '=': if(state==EYE_A||state==BODY_A1){state=BODY_A1;++count;} else if(state==STOMACH_A||state==BODY_A2){state=BODY_A2;--count;} else{return 2;} break; case '#': if(state==BODY_A1){state=STOMACH_A;} else{return 2;} break; case '~': if(state==BODY_A2&&count==0){state=TAIL_A;} else if(state==BODY_B){state=TAIL_B;count=1;} else if(state==TAIL_B){++count;} else{return 2;} break; } } if(state==TAIL_B&&count!=2)return 2; return state==TAIL_A?0:1; } void io() { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); for(int i=0;i<n;++i) { String str=sc.next(); switch(solve(str)) { case 0: System.out.println('A'); break; case 1: System.out.println('B'); break; case 2: System.out.println("NA"); break; } } } public static void main(String[] args) { // TODO Auto-generated method stub new Main().io(); } }
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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main() { int cnt, cnt2; int i; char snake[201]; scanf("%d", &cnt); for (i = 0; i < cnt; i++) { scanf("%s", snake); if (strlen(snake) < 2 || snake[0] != '>') { printf("NA\n"); } else if (snake[1] == '\'') { cnt2 = 0; i = 2; while (snake[i] == '=') { i++; cnt2++; } if (snake[i] != '#' || cnt2 <= 0) { printf("NA\n"); } else { i++; while (snake[i] == '=') { i++; cnt2--; } if (cnt2 != 0) { printf("NA\n"); } else if (snake[i] != '~' || snake[i + 1] != 0) { printf("NA\n"); } else { printf("A\n"); } } } else if (snake[1] == '^') { i = 2; while (snake[i] == 'Q' && snake[i + 1] == '=') { i += 2; } if (i == 2) { printf("NA\n"); } else if (snake[i] != '~' || snake[i + 1] != '~' || snake[i + 2] != 0) { printf("NA\n"); } else { printf("B\n"); } } else { printf("NA\n"); } } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { StringBuilder sb = new StringBuilder(); int n = int.Parse(Console.ReadLine()); while (n-- > 0) { string input = Console.ReadLine().Trim(); if (input[0] != '>' || input.Length % 2 == 1) { sb.AppendLine("NA"); continue; } switch (input[1]) { case '\'': if (CheckA(input)) sb.AppendLine("A"); else sb.AppendLine("NA"); break; case '^': if (CheckB(input)) sb.AppendLine("B"); else sb.AppendLine("NA"); break; default: sb.AppendLine("NA"); break; } } Console.Write(sb); } static bool CheckA(string s) { if (s[s.Length - 1] != '~') return false; string sub = s.Substring(2, s.Length - 3); string[] arr = sub.Split('#'); if (arr.Length != 2 || arr[0].Length != arr[1].Length) return false; for (int i = 0; i < arr[0].Length; i++) { if (arr[0][i] != '=') return false; if (arr[1][i] != '=') return false; } return true; } static bool CheckB(string s) { if (s[s.Length - 1] != '~' || s[s.Length - 2] != '~') return false; string sub = s.Substring(2, s.Length - 4); for (int i = 0; i < sub.Length; i += 2) { if (sub[i] != 'Q') return false; if (sub[i + 1] != '=') return false; } return true; } } }
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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { string str; int N; cin >> N; for (int i = 0; i < N; i++) { cin >> str; string x = " "; if (str[0] == '>') { for (int j = 0; j < 2; j++) x[j] = str[j]; if (str[1] == '\'' && str[str.size() - 1] == '~') { bool f = true; int C = 0; int mid = (2 + str.size() - 2) / 2; for (int j = 2; j <= str.size() - 2; j++) { if (j != mid && str[j] != '=') { f = false; } else if (j == mid && str[j] != '#') f = false; if (str[j] == '=') C++; } if (C % 2 != 0 || C == 0) f = false; if (f == true) cout << "A" << endl; else cout << "NA" << endl; } else if (str[1] == '^' && str[str.size() - 1] == '~' && str[str.size() - 2] == '~') { bool f = true; int C = 0; for (int j = 2; j < str.size() - 2; j++) { C++; if (C % 2 == 0 && str[j] != '=') f = false; if (C % 2 == 1 && str[j] != 'Q') f = false; } if (C % 2 != 0 || C == 0) f = false; if (f == true) cout << "B" << endl; else cout << "NA" << endl; } } else cout << "NA" << endl; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; string solv(string s) { int ss = s.size(); if (s[0] != '>' || s[ss - 1] != '~') return "NA"; if (s[ss - 2] == '~') { for (int i = 0; i < ss - 2; i++) { if (s[i] == 'Q') return "B"; } } else { int a = 0, f = 0; for (int i = 1; i < ss - 1; i++) { if (s[i] == '=' && !f) a++; if (s[i] == '#') f = 1; if (s[i] == '=' && f) a--; } return a ? "NA" : "A"; } return "NA"; } int main() { int n; cin >> n; string s; while (n--) { cin >> s; cout << solv(s) << endl; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
t;short*p;Q(){for(;*p=='=Q';p++);}main(i,s,a){for(;~scanf("%[^\n]\n",s);i=0)i||puts(sscanf(s,">^%[Q=]~%c%c",a,&t,a)-2||t-'~'|(Q(p=a),*p&7|p==a)?sscanf(s,">'%[=]#%[=]%c%c",a,s,&t,a)-3||t-'~'|strcmp(a,s)?"NA":"A":"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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; char str_input[110] = {NULL}; void f_syokika(); int f_A(int); bool f_B(); const char str_A[] = ">'=#~"; const char str_B[] = ">^Q=~~"; int main(void) { int n = 0; cin >> n; for (int i = 0; i < n; i++) { f_syokika(); cin >> str_input; bool flag_A = false; bool flag_B = false; int ikoru = 0; int count_h_A = 0; int count_h_B = 0; bool flag_NA = true; int count = 0; if (str_input[count++] == str_A[count_h_A]) { count_h_A++; count_h_B++; if (str_input[1] == str_A[count_h_A]) { count_h_A++; count++; while (str_input[count] != '\0') { if (str_input[count] != '=' && str_input[count] != '#' && str_input[count] != '~') { break; } if (str_input[count] == '#') { int kettei = 0; if ((kettei = f_A(count)) == -1) { cout << "NA" << endl; break; } if (str_input[kettei] == '~' && str_input[kettei + 1] == '\0') { cout << "A" << endl; } else { cout << "NA" << endl; } } count++; } } else if (str_input[1] == str_B[count_h_B]) { count_h_B++; count++; if (f_B() == true) { cout << "B" << endl; } else { cout << "NA" << endl; } } else { cout << "NA" << endl; } } else { cout << "NA" << endl; } } return 0; } void f_syokika() { for (int i = 0; i < 110; i++) { str_input[i] = '\0'; } } int f_A(int index) { int usiro = index - 1; int mae = index + 1; int count_usiro = 0; int count_mae = 0; while (true) { if (usiro < 0) { break; } if (str_input[usiro] != '=') { break; } count_usiro++; usiro--; } while (str_input[mae] == '=') { mae++; count_mae++; } if (count_usiro == count_mae && count_usiro != 0) { return mae; } return -1; } bool f_B() { int count_Q = 0; int count_ikoru = 0; int i = 2; while (str_input[i] == 'Q') { count_Q++; i += 2; } i = 3; while (str_input[i] == '=') { count_ikoru++; i += 2; } if (count_Q != count_ikoru) { return false; } if (str_input[i - 1] == '~' && str_input[i] == '~' && str_input[i + 1] == '\0') { return true; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, i; string s, t; cin >> n; while (n--) { cin >> s; t = s.substr(0, 2); s = s.substr(2); if (t == ">'") { t = s.substr(s.length() - 1); s = s.substr(0, s.length() - 1); if (t == "~" && (s.length() % 2) == 1) { for (i = 0; i < s.length(); i++) { if (i != s.length() / 2 && s[i] != '=' || i == s.length() / 2 && s[i] != '#') break; } if (i == s.length()) cout << "A" << endl; else cout << "NA" << endl; } else cout << "NA" << endl; } else if (t == ">^") { t = s.substr(s.length() - 2); s = s.substr(0, s.length() - 2); if (t == "~~" && (s.length() % 2) == 0) { for (i = 0; i < s.length(); i++) { if ((i % 2) == 0 && s[i] != 'Q' || (i % 2) == 1 && s[i] != '=') break; } if (i == s.length()) cout << "B" << endl; else cout << "NA" << endl; } else cout << "NA" << endl; } else cout << "NA" << endl; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main(void) { int quantity, i, j, idx, count = 0; char snake[200] = {0}; scanf("%d", &quantity); for (i = 0; i < quantity; i++) { scanf("%s", snake); if (snake[0] != '>') { puts("NA"); } else if (snake[1] == '\'') { for (j = 2; j < 199; j++) { if (snake[j] == '=') { count++; } else if (snake[j] == '#') { idx = j; break; } } for (j = idx + 1; j < 199; j++) { if (snake[j] != '=') { idx = j; break; } count--; } if (count == 0) { if (snake[idx] == '~' && snake[idx + 1] == '\0') puts("A"); else puts("NA"); } else { puts("NA"); } } else if (snake[1] == '^') { for (j = 2; j < 198; j += 2) { if (snake[j] == 'Q') count++; if (snake[j + 1] == '=') count--; if (snake[j] == '~' && snake[j + 1] == '~') { idx = j; break; } } if (count == 0 && (snake[idx] == '~' && snake[idx + 1] == '~')) puts("B"); else puts("NA"); } } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> void Atype(); void Btype(); void wrong(); int A, B; char b[201]; int main() { int n, i; char a, C[10000][3]; scanf("%d", &n); for (i = 0; i < n; i++) { A = 0; B = 0; scanf("%s", b); if (b[0] != '>') wrong(); else { if (b[1] == '\'') Atype(); else if (b[1] == '^') Btype(); else wrong(); } if (A == 0) { strcpy(C[i], "A"); } else if (B == 0) { strcpy(C[i], "B"); } else { strcpy(C[i], "NA"); } } for (i = 0; i < n; i++) printf("%s\n", C[i]); return 0; } void Atype() { B = 1; int x, y, i; char c; x = 0; y = 0; while (1) { if (b[2 + x] != '=') { break; } x++; } if (b[2 + x] != '#') wrong(); while (1) { if (b[3 + x + y] != '=') { break; } y++; } if (x != y) wrong(); if (b[3 + x + y] != '~') wrong(); if (b[4 + x + y] != '\0') wrong(); } void Btype() { A = 1; int x = 1; char c, q; while (1) { if (b[2 * x] == 'Q' && b[2 * x + 1] == '=') { x++; continue; } else break; } if (b[2 * x] == '~' && b[2 * x + 1] == '~') B = 0; else wrong(); if (b[2 * x + 2] != '\0') wrong(); } void wrong() { A = 1; B = 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
for _ in [0]*int(input()): s=input() if s[1]=='\'': l=s.find('#') r=s.rfind('~') print('A' if l-1==r-l else 'NA') else: r=s.rfind('~~') print('B' if s[1:r].count('Q')==s[1:r].count('=') else '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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { StringBuilder sb = new StringBuilder(); int n = int.Parse(Console.ReadLine()); while (n-- > 0) { string input = Console.ReadLine(); if (input[0] != '>') { sb.AppendLine("NA"); continue; } switch (input[1]) { case '\'': int idx = 2, count = 0; while (input[idx] == '=' && idx < input.Length) { count++; idx++; } string temp = new string(Enumerable.Repeat('=', count).ToArray()); string makeA = ">'" + temp + "#" + temp + "~"; if (input == makeA) sb.AppendLine("A"); else sb.AppendLine("NA"); break; case '^': int vol = input.Length / 2 - 2; string makeB = ">^"; for (int i = 0; i < vol; i++) { makeB += "Q="; } makeB += "~~"; if (input == makeB) sb.AppendLine("B"); else sb.AppendLine("NA"); break; default: sb.AppendLine("NA"); break; } } Console.Write(sb); } } }
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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; signed main() { long long n; cin >> n; for (long long i = 0; i < n; i++) { string s; cin >> s; long long ans = 0; long long sz = s.size(); if (s[0] == '>' && s[1] == '\'' && s[sz - 1] == '~' && sz % 2 == 0 && s[sz / 2] == '#') { for (long long i = 2; i < sz - 1; i++) { if (i != sz / 2 && s[i] != '=') { ans = -1; break; } if (i == sz - 2) ans = 1; } } else if (s[0] == '>' && s[1] == '^' && s[sz - 2] == '~' && s[sz - 1] == '~' && sz % 2 == 0) { for (long long i = 2; i < sz - 2; i++) { if (i % 2 == 0 && s[i] != 'Q') { ans = -1; break; } if (i % 2 && s[i] != '=') { ans = -1; break; } if (i == sz - 3) ans = 2; } } else { ans = -1; } if (ans == -1) cout << "NA" << endl; else if (ans == 1) cout << "A" << endl; else if (ans == 2) cout << "B" << endl; } }
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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int solve(string &s) { int t = -1; if (s.length() < 3) return -1; if (s.length() >= 3 && s.substr(0, 2) == ">'" && s[(int)s.length() - 1] == '~') t = 0; if (s.length() >= 4 && s.substr(0, 2) == ">^" && s.substr((int)s.length() - 2) == "~~") t = 1; if (t == -1) return -1; if (t) { for (int i = 2; i + 3 < s.length(); i += 2) if (s.substr(i, 2) != "Q=") return -1; return t; } else { int c1 = 0, c2 = 0, i = 2; for (; i + 1 < s.length() && s[i] == '='; ++i) ++c1; if (s[i++] != '#') return -1; for (; i + 1 < s.length() && s[i] == '='; ++i) ++c2; if (c1 != c2 || s[i] != '~' || i + 1 != (int)s.length()) return -1; return t; } return -1; } int main() { int T; cin >> T; for (int t = 0; t < (int)(T); ++t) { string s; cin >> s; int ans = solve(s); cout << (ans == 0 ? "A" : (ans == 1 ? "B" : "NA")) << endl; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> const double PI = acos(-1); using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { string ans; string s; cin >> s; if (s[0] != '>') { cout << "NA" << endl; continue; } if (s[1] == '^') { ans = 'B'; int h = 2; while (s[h++] == 'Q' && s[h++] == '=') ; h--; if (s[h++] != '~' || s[h++] != '~') ans = "NA"; if (h != s.size()) ans = "NA"; } else if (s[1] == '\'') { ans = 'A'; int h1 = 0, h2 = 0; int j = 1; while (s[++j] == '=') h1++; if (s[j] != '#') ans = "NA"; while (s[++j] == '=') h2++; if (s[j] != '~') ans = "NA"; if (++j != s.size()) ans = "NA"; if (h1 != h2) ans = "NA"; } cout << ans << endl; } }
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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; for (int i = 0; i < N; i++) { string sn; cin >> sn; int type = 0; if (sn[0] == '>' && sn[1] == 39) type = 1; if (sn[0] == '>' && sn[1] == '^') type = 2; int flg = 1; if (type == 1) { int cou = 0; int aftercou = 0; int p; for (int j = 2; j < sn.size(); j++) { if (sn[j] == '=') cou++; else if (sn[j] == '#') { p = j; break; } else { flg = 0; goto syutu; } } for (int k = p + 1; k < sn.size(); k++) { if (sn[k] == '=') aftercou++; else if (sn[k] == '~' && k == sn.size() - 1) { if (cou != aftercou) flg = 0; goto syutu; } else { flg = 0; goto syutu; } } if (sn[sn.size() - 1] != '~') flg = 0; syutu: if (flg) puts("A"); else puts("NA"); } else if (type == 2) { for (int j = 2; j < sn.size() - 1; j += 2) { if (sn[j] == '~' && sn[j + 1] == '~') break; if (!(sn[j] == 'Q' && sn[j + 1] == '=')) flg = 0; } if (sn[sn.size() - 2] != '~' || sn[sn.size() - 1] != '~') flg = 0; if (flg) puts("B"); else puts("NA"); } else puts("NA"); } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while (n--) { string str; cin >> str; if (str[0] != '>') cout << "NA" << endl; else { if (str[1] == '\'' && str[2] == '=') { int e = 2; for (; str[e] == '='; e++) ; if (str[e] == '#') { int f = e + 1; for (; str[f] == '='; f++) ; if (e == f - e + 1 && str[f] == '~' && str[f + 1] == '\0') cout << "A" << endl; else cout << "NA" << endl; } else cout << "NA" << endl; } else if (str[1] == '^') { int e, flg = 0; for (e = 2; str[e] == 'Q'; e += 2) { if (str[e + 1] != '=') { cout << "NA" << endl; flg = 1; break; } } if (!flg) { if (str[e] == '~' && str[e + 1] == '~' && str[e + 2] == '\0') cout << "B" << endl; else cout << "NA" << endl; } } else cout << "NA" << endl; } } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main(void) { int max, num; int total; int i; char snake[201]; scanf("%d", &max); for (num = 0; num < max; num++) { scanf("%s", snake); if (strlen(snake) < 2 || snake[0] != '>') { printf("NA"); continue; } if (snake[1] == '\'') { total = 0; i = 2; while (snake[i] == '=') { i++; num++; } if (snake[i] != '#' || num <= 0) printf("NA"); else { i++; while (snake[i] == '=') { i++; num--; } if (num != 0) printf("NA\n"); else if (snake[i] != '~' || snake[i + 1] != 0) printf("NA"); else printf("A"); } } else if (snake[1] == '^') { i = 2; while (snake[i] == 'Q' && snake[i + 1] == '=') i += 2; if (i == 2) printf("NA\n"); else if (snake[i] != '~' || snake[i + 1] != '~' || snake[i + 2] != 0) printf("NA"); else printf("B"); } else printf("NA"); } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; struct cww { cww() { ios::sync_with_stdio(false); cin.tie(0); } } star; bool check_A(string S) { auto sz = S.size(); if (S.find(">'") == 0 && S.find("~") == sz - 1 && sz >= 6) { S = S.substr(2, sz - 3); sz = S.size(); if (S.find_first_not_of("#=", 0) != string::npos) { return 0; } auto pos = S.find("#"); if (S.find("#", pos + 1) != string::npos) { return 0; } return S[sz / 2] == '#' ? 1 : 0; } return 0; } bool check_B(string S) { auto sz = S.size(); if (S.find(">^") == 0 && S.find("~~") == sz - 2 && sz >= 6) { S = S.substr(2, sz - 4); sz = S.size(); if (sz % 2 != 0) { return 0; } for (int i = 0; i < sz; i += 2) { if (S[i] != 'Q' && S[i + 1] != '=') { return 0; } } return 1; } return 0; } int main() { int N; cin >> N; vector<string> res{"NA", "A", "B"}; for (int i = 0; i < (N); i++) { string S; cin >> S; cout << res[check_A(S) ? 1 : check_B(S) ? 2 : 0] << endl; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main(int argc, const char* argv[]) { int num; int i, j, k, l; char snake[200]; int bodyacnt = 0; int bodybcnt = 0; int midcnt = 0; int endacnt = 0; int endbcnt = 0; int nacnt = 0; scanf("%d", &num); for (l = 0; l < num + 1; l++) { snake[200] = {0}; bodyacnt = 0; bodybcnt = 0; midcnt = 0; endacnt = 0; endbcnt = 0; nacnt = 0; for (i = 0; i < 200; i++) { scanf("%c", &snake[i]); if (snake[i] == '\n') { break; } } if (snake[0] == '>') { if (snake[1] == '\'') { for (j = 2; j < i; j++) { if (snake[j] == '=') { bodyacnt++; } else if (snake[j] == '#') { break; } else nacnt++; } for (k = j; k < i; k++) { if (snake[k] == '=') { midcnt++; } else if (snake[k] == '~') { endacnt++; if (endacnt == 2) { nacnt++; } } else nacnt++; } } else if (snake[1] == '^') { for (j = 2; j < i / 2; j += 2) { if (snake[j] == 'Q' && snake[j + 1] == '=') { bodybcnt++; } else nacnt++; } if (snake[i - 2] == '~' && snake[i - 1] == '~' && snake[i - 3] != '~') { endbcnt++; } } else nacnt++; } if (bodybcnt > 0 && endbcnt == 1 && nacnt == 0) { printf("B\n"); } else if (bodyacnt == midcnt && endacnt == 1 && nacnt == 0 && bodyacnt > 0) { printf("A\n"); } else if (l != 0) printf("NA\n"); } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> 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; } int flg = 0, sum; if (str[1] == '\'') { int t = 0; sum = 0; for (int i = 2; i < str.size(); i++) { if (str[i] == '=') t++; else if (str[i] == '#' && sum == 0) sum = t, t = 0; else if (str[i] == '~' && i == str.size() - 1 && sum == t) flg = 1; else break; } } if (str[1] == '^' && flg == 0) { flg = 0; for (int i = 2; i < str.size(); i++) { if (i % 2 == 0 && str[i] != 'Q') break; if (i % 2 == 1 && str[i] != '=') break; if (str[str.size() - 2] == '~' && str[str.size() - 1] == '~' && i == str.size() - 3 && i % 2 == 1) { flg = 2; break; } } } if (flg == 0) cout << "NA" << endl; else if (flg == 1) cout << "A" << endl; else if (flg == 2) cout << "B" << endl; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while (n--) { string s; cin >> s; if (s[0] == '>') { if (s[1] == '\'') { int sum = 0; for (int i = 0; i < s.size(); i++) if (s[i] == '=') sum++; if (s.size() % 2 == 0 && s[s.size() / 2] == '#' && sum == s.size() - 4 && s[s.size() - 1] == '~') cout << 'A' << endl; else goto L; } else if (s[1] == '^') { int c = 2; if (s.size() % 2 || s.size() < 6) goto L; while (c < s.size() - 3) { if (s[c] != 'Q') goto L; c++; if (s[c] != '=') goto L; c++; } if (s[c] == '~' && s[c + 1] == '~') cout << 'B' << endl; else goto L; } else goto L; } else goto L; if (0) L: cout << "NA" << endl; } }
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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int i, count; string s, name; getline(cin, s); while (getline(cin, s)) { if (s[1] == '\'') { name = "A"; if (s[2] != '=') name = "NA"; else { count = 0; for (i = 2; s[i] == '='; i++) count++; if (s[i] != '#') name = "NA"; else { for (; count > 0; count--) if (s[++i] != '=') { name = "NA"; break; } if (s[++i] != '~' || i != s.size() - 1) name = "NA"; } } } else if (s[1] == '^') { name = "B"; for (i = 2; i < s.size() - 2; i += 2) { if (s.size() & 1) { if (s[i + 2] != '~' || s[i + 3] != '~') name = "NA"; break; } if (s[i] != 'Q' || s[i + 1] != '=') { if (s[i + 2] != '~' || s[i + 3] != '~') name = "NA"; break; } } } cout << name << endl; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; while (N--) { string str; cin >> str; bool Aflag, Bflag; Aflag = Bflag = true; if (str.length() < 6) Aflag = Bflag = false; if (str.substr(0, 2) == ">'") Bflag = false; else if (str.substr(0, 2) == ">^") Aflag = false; else Aflag = Bflag = false; if (Aflag) { int p = str.find("#"); if (p == str.npos) { Aflag = false; break; } int cnt = 0; for (int i = 2; i < p; i++) { if (str[i] == '=' && str[p + i - 1] == '=') cnt++; else { Aflag = false; break; } } if (str[cnt * 2 + 3] == '~' && str.length() == cnt * 2 + 4) ; else Aflag = false; } if (Bflag) { int p = 2; while (str.substr(p, 2) == "Q=") p += 2; if (str.substr(p, p + 2) == "~~" && str.length() == p + 2) ; else Bflag = false; } if (Aflag) cout << "A" << endl; else if (Bflag) cout << "B" << endl; else cout << "NA" << endl; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(void) { string str; int n; cin >> n; while (n--) { cin >> str; int ca = 0; int cntsha = 0; bool a = true; if (str.size() % 2 == 0 && str[0] == '>' && str[1] == '\'' && str[str.size() - 1] == '~') { if (str[str.size() / 2] == '#') str[str.size() / 2] = '='; for (int i = 2; i < str.size() - 1; i++) { if (str[i] != '=') { a = false; break; } } if (a) ca = 1; } if (ca != 1 && str[0] == '>' && str[1] == '^' && str[str.size() - 2] == '~' && str[str.size() - 1] == '~') { bool b = true; for (int i = 2; i < str.size() - 2; i++) { if (i % 2) { if (str[i] != '=') { b = false; break; } } else { if (str[i] != 'Q') { b = false; break; } } } if (b) { ca = 2; } } if (ca == 1) { cout << "A" << endl; } else if (ca == 2) { cout << "B" << endl; } else { cout << "NA" << endl; } } }
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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
import scala.io.StdIn.{readInt,readLine} object Main { def find(s:String) = { if(s.length<4) "NA" else if(s(0)=='>') { if(s(1) == ''') { // maybeA var isA = true val s2 = s.drop(2).dropRight(1) if(s2(s2.length/2) != '#') isA = false else { val s3 = s2.split("#") if(s3(0)!=s3(1) || s3(0).exists(_!='=')) isA = false } if(isA && s(s.length-1)=='~') "A" else "NA" } else if (s(1) == '^') { // maybeB var isB = true for(i<-2 until s.length-2 by 2) { if(s(i)!='Q' || s(i+1)!='=') { isB = false } } if(isB && s(s.length-2)=='~' && s(s.length-1)=='~') "B" else "NA" } else { "NA" } } else "NA" } def main(args:Array[String]) = { val n = readInt for(i<-1 to n) { val s = readLine.trim println(find(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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
char*p,s[102],a[101],b[101];short*q,l;B(r){r=l=0;if(*(q=s)=='^>'){for(;*++q=='=Q';)l++;if(l&&*q++=='~~'&&!*(p=q))r=1;}return r;}main(t,r){for(;~scanf("%*d\n%[^\n]\n"+!!*s*4,s);)puts(sscanf(s,">'%[=]#%[=]%c%c",a,b,&t,r)==3&t=='~'&strlen(a)==strlen(b)?"A":B()?"B":"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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while (n--) { string s; cin >> s; int a = 0, b = 0, k = -1; bool f = false; for (int i = 0; i < s.size(); i++) if (s[i] == '>') k = i; if (k != -1) { if (s[k + 1] == '^') { f = false; for (int i = k; i < s.size() - 1; i++) { if (s[i] == 'Q' && s[i + 1] == '=') f = true; } if (f && s[s.size() - 1] == '~' && s[s.size() - 2] == '~') { cout << "B" << endl; continue; } } int cnt = 0; f = false; while (k < s.size()) { if (s[k] == '=') { while (s[k] == '=') { cnt++; k++; } break; } k++; } if (s[k] == '#') f = true; while (k < s.size()) { if (s[k] == '=') { while (s[k] == '=') { cnt--; k++; } break; } k++; } if (f && cnt == 0) { cout << "A" << endl; continue; } } cout << "NA" << endl; } }
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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; void a() { cout << "NA" << endl; return; } int main() { int n; cin >> n; for (int i = 0; i < n; i++) { string snake; cin >> snake; string::size_type aruyon; if ((aruyon = snake.find(">'")) == 0) { int equal = 0; int j; for (j = 2; snake.at(j) == '='; j++) equal++; if (equal > 0) if (snake.at(j) == '#') { j++; for (; snake.at(j) == '='; j++) equal--; if (equal == 0) { if (snake.at(j) == '~' && j + 1 == snake.size()) cout << 'A' << endl; else a(); } else a(); } else a(); else a(); } else if ((aruyon = snake.find(">^")) == 0) { int j; bool dou = false; if ((aruyon = snake.find("~~")) == snake.size() - 2) { if (aruyon % 2 == 0) { for (j = 2; j < aruyon; j++) { dou = false; if (snake.at(j) == 'Q') j++; else { j = 0; break; } if (snake.at(j) != '=') { a(); break; } else dou == true; } if (dou) cout << 'B' << endl; else a(); } else a(); } else a(); } else a(); } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; bool A(string body) { if (int a = body.find("#") != -1 && body.size() % 2 == 0 && body.substr(body.size() - 1, 1) == "~" && body.size() >= 4) { for (int i = 0; i < a; i++) { if (body.substr(i, 1) == body.substr(body.size() - 2 - i, 1) && body.substr(i, 1) == "=") { continue; } else return false; } } else return false; return true; } bool B(string body) { if (body.substr(body.size() - 2, 2) == "~~" && body.size() % 2 == 0 && body.size() >= 4) { for (unsigned int i = 0; i < body.size() - 2; i += 2) { if (body.substr(i, 2) == "Q=") { continue; } else return false; } } else return false; return true; } int main() { int n; string str; scanf("%d\n", &n); for (int i = 0; i < n; i++) { getline(cin, str); if (str.substr(0, 2) == ">'") { if (A(str.substr(2))) cout << "A" << endl; else cout << "NA" << endl; } else if (str.substr(0, 2) == ">^") { if (B(str.substr(2))) cout << "B" << endl; else cout << "NA" << endl; } else cout << "NA" << endl; } }
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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int checkA(char str[]) { int i; int cnt = 0; if (str[strlen(str) - 1] != '~') return 0; for (i = 2; i < strlen(str); i++) { if (str[i] == '=') cnt++; else if (str[i] == '#') break; else return 0; } i++; while (i < strlen(str)) { if (i == strlen(str) - 1) { if (cnt == 0) { printf("A\n"); return 1; } else return 0; } else { if (str[i] == '=') cnt--; else return 0; } i++; } return 0; } int checkB(char str[]) { int i; if (str[strlen(str) - 2] != '~' || str[strlen(str) - 1] != '~') return 0; for (i = 2; i < strlen(str) - 2; i++) { if (i % 2 == 0) { if (str[i] != 'Q') return 0; } else { if (str[i] != '=') return 0; } } printf("B\n"); return 1; } int main() { int n, i; int c; char snk[201]; scanf("%d", &n); for (i = 0; i < n; i++) { c = 0; scanf("%s", snk); if (snk[0] == '>' && snk[1] == '\'') c = checkA(snk); if (snk[0] == '>' && snk[1] == '^') c = checkB(snk); if (c == 0) printf("NA\n"); } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main(void) { int n, len, flag = 0, flag2 = 0, cnt1 = 0, cnt2 = 0; char snake[10000][200]; cin >> n; for (int i = 0; i < n; i++) { scanf("%s", snake[i]); len = strlen(snake[i]); if (snake[i][0] == '>' && snake[i][1] == '\'') { for (int j = 2; j < len - 1; j++) { if (snake[i][j] == '=' && flag == 0) { cnt1++; flag2 = 1; } if (snake[i][j] == '=' && flag == 1) { cnt2++; flag2 = 1; } if (snake[i][j] == '#') flag = 1; } if (snake[i][len - 1] == '~' && cnt1 == cnt2 && flag2 == 1) { cout << 'A' << endl; flag = 0; flag2 = 0; cnt1 = 0; cnt2 = 0; } else { cout << "NA" << endl; flag = 0; flag2 = 0; cnt1 = 0; cnt2 = 0; } } else if (snake[i][0] == '>' && snake[i][1] == '^') { for (int j = 2; j < len - 2; j++) { if (snake[i][j] == 'Q' && snake[i][j + 1] == '=') flag = 1; } if (snake[i][len - 2] == '~' && snake[i][len - 1] == '~' && flag == 1) { cout << 'B' << endl; flag = 0; } else { cout << "NA" << endl; flag = 0; } } else { cout << "NA" << endl; flag = 0; } } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; string solv(string s) { int ss = s.size(); if (s[0] != '>' || s[ss - 1] != '~') return "NA"; if (s[ss - 2] == '~') { if (s[1] != '^') return "NA"; for (int i = 0; i < ss - 2; i++) { if (s[i] == 'Q' && s[i + 1] == '=') return "B"; } } else { int a = 0, f = 0; for (int i = 1; i < ss - 1; i++) { if (s[i] == '=' && !f) a++; if (s[i] == '#') f = 1; if (f && !a) return "NA"; if (s[i] == '=' && f) a--; } return a ? "NA" : "A"; } return "NA"; } int main() { int n; cin >> n; string s; while (n--) { cin >> s; cout << solv(s) << endl; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while (n--) { string s; cin >> s; int f1 = 0, f2 = 0, k = -1; bool f; for (int i = 0; i < s.size(); i++) if (s[i] == '>') { k = i; break; } if (k == -1 || s.size() < 5) { printf("NA\n"); continue; } if (s[k + 1] == '^') { f = false; for (int i = k; i + 1 < s.size(); i++) if (s[i] == 'Q' && s[i + 1] == '=') f = true; if (f && s[s.size() - 1] == '~' && s[s.size() - 2] == '~') { printf("B\n"); continue; } } int cnt = 0, cnt1 = 0; for (int i = k; i < s.size(); i++) { if (s[i] == '=') { while (s[i] == '=' && i < s.size()) { cnt++; i++; } k = i; break; } } f = false; for (int i = k; i < s.size(); i++) { if (s[i] == '#') { k = i; f = true; } } if (f) { for (int i = k; i < s.size(); i++) { if (s[i] == '=') { while (s[i] == '=' && i < s.size()) { cnt1++; i++; } break; } } if (cnt == cnt1 && s[s.size() - 1] == '~') { printf("A\n"); continue; } } printf("NA\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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-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]=='~') { int co=2; while(ch[co]!='#') { if(ch[co]=='=') counta++; co++; if(co==ch.length-1) break; } while(ch[co]!='~') { if(ch[co]=='=') countb++; co++; } if(counta==countb&&counta>0) System.out.println("A"); else System.out.println("NA"); continue; } else if(ch[0]=='>'&&ch[1]=='^' &&ch[ch.length-1]=='~'&&ch[ch.length-2]=='~') { int co=2; while(ch[co]!='~') { if(ch[co]=='Q'&&ch[co+1]=='=') flag = true; else { flag = false; break; } co+=2; } } System.out.println(flag==true ? "B":"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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n; string s; int main() { cin >> n; for (; n--;) { cin >> s; string t = "NA"; if (s.substr(0, 2) == ">'") { int cnt = 0; int i = 2; while (i < s.size() && s[i] == '=') i++, cnt++; if (s[i] == '#') { int j = i + 1; while (j < s.size() && s[j] == '=') j++, cnt--; if (cnt == 0 && j + 1 == s.size() && s.substr(j, 1) == "~") t = "A"; } } else if (s.substr(0, 2) == ">^") { int i = 2; while (i + 2 < s.size() && s.substr(i, 2) == "Q=") i += 2; if (i > 2 && i + 2 == s.size() && s.substr(i, 2) == "~~") { t = "B"; } } cout << t << endl; } }
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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while (n--) { string s; cin >> s; int f1 = 0, f2 = 0, k = -1; bool f; for (int i = 0; i < s.size(); i++) if (s[i] == '>') k = i; if (k == -1) { printf("NA\n"); continue; } if (s[k + 1] == '^') { f = false; for (int i = k; i < s.size() - 1; i++) if (s[i] == 'Q' && s[i + 1] == '=') f = true; if (f && s[s.size() - 1] == '~' && s[s.size() - 2] == '~') { printf("B\n"); continue; } } int cnt = 0; for (int i = k; i < s.size(); i++) { if (s[i] == '=') { while (s[i] == '=' && i < s.size()) { cnt++; i++; } k = i; break; } } f = false; for (int i = k; i < s.size(); i++) { if (s[i] == '#') { k = i; f = true; } } if (f) { for (int i = k; i < s.size(); i++) { if (s[i] == '=') { while (s[i] == '=' && i < s.size()) { cnt--; i++; } break; } } if (cnt == 0 && s[s.size() - 1] == '~') { printf("A\n"); continue; } } printf("NA\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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main(void) { char A, B; char snake[256]; int n; int cnt; int i, j, len1, len2; scanf("%d", &n); for (i = 0; i < n; i++) { A = B = 0; scanf("%s", snake); if (snake[0] == '>' && snake[1] == '\'') { j = 2; len1 = 0; while (snake[j] != '#' && snake[j] != '\0') { len1++; j++; } if (snake[j] == '#') { j++; } len2 = 0; while (snake[j] != '~' && snake[j] != '\0') { len2++; j++; } if (len1 == len2 && len1 > 0 && snake[j + 1] == '\0') { A = 1; } } else if (snake[0] == '>' && snake[1] == '^') { j = 2; len1 = 0; while (snake[j] != '~') { if (j % 2 == 0 && snake[j] != 'Q') { break; } if (j % 2 == 1 && snake[j] != '=') { break; } j++; len1++; } if (snake[j + 1] == '~' && len1 > 0 && len1 % 2 == 0) { B = 1; } } if (A) { printf("A\n"); } else if (B) { printf("B\n"); } else { printf("NA\n"); } } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; bool asnake(string s) { int n = s.size(); if (n % 2) return false; string com = ">\'"; for (int i = 0; i < (n - 4) / 2; i++) com += '='; com += '#'; for (int i = 0; i < (n - 4) / 2; i++) com += '='; com += '~'; if (s == com) return true; else return false; } bool bsnake(string s) { int n = s.size(); if (n % 2) return false; string com = ">^"; for (int i = 0; i < (n - 4) / 2; i++) com += "Q="; com += "~~"; if (s == com) return true; else return false; } int main() { int n; cin >> n; for (int p = 0; p < n; p++) { string s; cin >> s; if (asnake(s)) cout << "A" << endl; else if (bsnake(s)) cout << "B" << endl; else cout << "NA" << endl; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
UNKNOWN
#include <bits/stdc++.h> int main() { char s[201]; int n; fscanf(stdin, "%" "d", &n); while (n--) { fscanf(stdin, "%" "s", &s); int i, f = 0; if (s[1] == '\'') { int l, r; l = r = 0; for (i = 2; s[i] == '=' && s[i] != '\0'; l++, i++) ; for (++i; s[i] == '=' && s[i] != '\0'; r++, i++) ; if (l == r) puts("A"); else f = 1; } else if (s[1] == '^') { int q, e; q = e = 0; for (i = 2; (s[i] != '~' && s[i] != '~~') && s[i] != '\0'; i++) { if (s[i] == 'Q') q++; else if (s[i] == '=') e++; } if (q == e) puts("B"); else f = 1; } if (f) puts("NA"); } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> const double PI = acos(-1); using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { string ans; string s; cin >> s; if (s[0] != '>') { cout << "NA" << endl; continue; } if (s[1] == '^') { ans = 'B'; int h = 2; while (h < s.size() - 2) { if (s[h++] != 'Q' || s[h++] != '=') { ans = "NA"; break; } } if (s[h++] != '~' || s[h++] != '~') ans = "NA"; if (h != s.size()) ans = "NA"; } else if (s[1] == '\'') { ans = 'A'; int h1 = 0, h2 = 0; int j = 1; while (s[++j] == '=') h1++; if (s[j] != '#') ans = "NA"; while (s[++j] == '=') h2++; if (s[j] != '~') ans = "NA"; if (++j != s.size()) ans = "NA"; if (h1 != h2) ans = "NA"; } cout << ans << endl; } }
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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, i; string s, t; cin >> n; while (n--) { cin >> s; t = s.substr(0, 2); s = s.substr(2); if (t == ">'") { t = s.substr(s.length() - 1); s = s.substr(0, s.length() - 1); if (t == "~" && (s.length() % 2) == 1) { for (i = 0; i < s.length(); i++) { if (i != s.length() / 2 && s[i] != '=' || i == s.length() / 2 && s[i] != '#') break; } if (i >= s.length()) cout << "A" << endl; else cout << "NA" << endl; } else cout << "NA" << endl; } else if (t == ">^") { t = s.substr(s.length() - 2); s = s.substr(0, s.length() - 2); if (t == "~~" && (s.length() % 2) == 0) { for (i = 0; i < s.length(); i++) { if ((i % 2) == 0 && s[i] != 'Q' || (i % 2) == 1 && s[i] != '=') break; } if (i >= s.length()) cout << "B" << endl; else cout << "NA" << endl; } else cout << "NA" << endl; } else cout << "NA" << endl; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { bool b; int n, i, j, t, c[2]; char s[201]; cin >> n; for (i = 0; i < n; i++) { b = true; cin >> s; if (s[0] == '>') { if (s[1] == '\'') { for (j = 2, t = c[0] = c[1] = 0; j < strlen(s) - 1; j++) { if (s[j] == '=') c[t]++; else if (t == 0 && s[j] == '#') t++; else { b = false; break; } } if (b && c[0] == c[1] && s[strlen(s) - 1] == '~') cout << "A" << endl; else cout << "NA" << endl; continue; } else if (s[1] == '^') { for (j = 2; j < strlen(s) - 2; j += 2) { if (s[j] != 'Q' || s[j + 1] != '=') { b = false; break; } } if (b && s[strlen(s) - 2] == '~' && s[strlen(s) - 1] == '~') cout << "B" << endl; else b = false; continue; } else b = false; } else b = false; if (!b) cout << "NA" << endl; } }
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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n; for (int i = 0; i < (n); i++) { cin >> s; string ans; if (s.size() % 2 == 1) { ans = "NA"; } else if (s[0] == '>' && s[s.size() - 1] == '~') { if (s[1] == '\'') { ans = "A"; for (int i = 2; i < s.size() - 1; i++) { if (i == s.size() / 2) { if (s[i] != '#') { ans = "NA"; break; } } else { if (s[i] != '=') { ans = "NA"; break; } } } } else if (s[1] == '^' && s[s.size() - 2] == '~') { ans = "B"; for (int i = 2; i < s.size() - 2; i += 2) { if (s[i] != 'Q' || s[i + 1] != '=') { ans = "NA"; break; } } } else ans = "NA"; } else { ans = "NA"; } cout << ans << endl; } }
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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
python2
for r in range(input()): snake=raw_input() L=len(snake) if snake == ">'" + "="*((L-4)/2) + "#" + "="*((L-4)/2) + "~": print "A" elif snake == ">^" + "Q="*((L-4)/2) + "~~": 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-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]=='~'&&ch[ch.length-2]=='=') { int co=2; while(ch[co]!='#') { if(ch[co]=='=') counta++; co++; if(co==ch.length-1) break; } while(ch[co]!='~') { if(ch[co]=='=') countb++; co++; } if(counta==countb&&counta>0) System.out.println("A"); else System.out.println("NA"); continue; } else if(ch[0]=='>'&&ch[1]=='^' &&ch[ch.length-1]=='~'&&ch[ch.length-2]=='~') { for(int co=2;co<ch.length-2;co+=2) { if(ch[co]=='Q'&&ch[co+1]=='=') flag = true; else { flag = false; break; } } } System.out.println(flag==true ? "B":"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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; while (n-- > 0) { string s; cin >> s; cerr << s << endl; cout << "A" << endl; } 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 with "~~" after "> ^" followed by one or more "Q =". Example of type A:>'==== # ==== ~>'== # == ~ Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~ Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do. Input The input is given in the following format: n S1 S2 :: Sn The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to. Output Print the i-th snake type A, B or NA on line i. Example Input 3 >'======#======~ >^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~ >'===#====~ Output A B NA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n; for (int i = 0; i < (n); i++) { cin >> s; string ans; cout << s.size() << endl; if (s.size() % 2 == 1 || s.size() == 4) { ans = "NA"; } else if (s[0] == '>' && s[s.size() - 1] == '~') { if (s[1] == '\'') { ans = "A"; for (int i = 2; i < s.size() - 1; i++) { if (i == s.size() / 2) { if (s[i] != '#') { ans = "NA"; break; } } else { if (s[i] != '=') { ans = "NA"; break; } } } } else if (s[1] == '^' && s[s.size() - 2] == '~') { ans = "B"; for (int i = 2; i < s.size() - 2; i += 2) { if (s[i] != 'Q' || s[i + 1] != '=') { ans = "NA"; break; } } } else ans = "NA"; } else { ans = "NA"; } cout << ans << endl; } }
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
python3
for i in range(4): t,n=map(int,input().split()) if t==1: print(f'{6000*n}') elif t==2: print(f'{4000*n}') elif t==3: print(f'{3000*n}') elif t==4: print(f'{2000*n}')
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <stdio.h> int main(void){ int t,n; int i; for(i=0;i<4;i++){ scanf("%d %d",&t,&n); if(t==1){ printf("%d\n",6000*n); } if(t==2){ printf("%d\n",4000*n); } if(t==3){ printf("%d\n",3000*n); } if(t==4){ printf("%d\n",2000*n); } } return 0; }
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> using namespace std; int t[]={0,6000,4000,3000,2000},a,b; int main(){ while(cin>>a>>b){ cout<<t[a]*b<<endl; } return 0; }
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> #include <algorithm> using namespace std; int main(void){ for (int h = 1; h <= 4;h++){ int t, n, p; cin >> t >> n; switch (t){ case 1: p = 6000; break; case 2: p = 4000; break; case 3: p = 3000; break; case 4: p = 2000; break; } cout << p*n << endl; } }
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
python3
tn=[map(int,input().split()) for _ in range(4)] t,n=[list(i) for i in zip(*tn)] l=[] for x in range(4): if t[x]==1: l.append(6000*n[x]) elif t[x]==2: l.append(4000*n[x]) elif t[x]==3: l.append(3000*n[x]) else: l.append(2000*n[x]) print(l[0]) print(l[1]) print(l[2]) print(l[3])
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
python3
# coding: utf-8 # Your code here! for l in range(4): t,n = [int(i) for i in input().split()] if t == 1: print(6000*n) elif t == 2: print(4000*n) elif t == 3: print(3000*n) elif t == 4: print(2000*n)
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> using namespace std; int main(){ int kingaku[] = {6000, 4000, 3000, 2000}; //???????????? for (int i = 0; i < 4; i++) { int t,n; cin >> t >> n; cout << kingaku[t-1] * n << endl; } return 0; }
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
java
import java.util.Scanner; public class Main{ public static void main(String[]args){ int ban; int su; int kin; int s=6000,a=4000,b=3000,c=2000; Scanner sc = new Scanner(System.in); for(int i=0;i<4;i++){ ban = sc.nextInt(); su = sc.nextInt(); switch(ban){ case 1: kin = s*su; System.out.println(kin); break; case 2: kin = a*su; System.out.println(kin); break; case 3: kin = b*su; System.out.println(kin); break; case 4: kin = c*su; System.out.println(kin); break; } } } }
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <cstdio> int main() { int t,n; for(int i=0;i<4;i++) { scanf("%d %d",&t,&n); int sale; if(t==1) sale=6000*n; if(t==2) sale=4000*n; if(t==3) sale=3000*n; if(t==4) sale=2000*n; printf("%d\n",sale); } }
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<cstdio> #include<cmath> #include<iostream> #include<algorithm> #include<queue> using namespace std; int main(){ int lis[5]={0,6000,4000,3000,2000}; for(int i=0;i<4;i++){ int a,b; scanf("%d %d",&a,&b); printf("%d\n",lis[a]*b); } return 0; }
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <stdio.h> int main(void){ int a; int t,n; int i; for(i=0;i<4;i++){ scanf("%d %d",&t,&n); if(t==1)t=6000; if(t==2)t=4000; if(t==3)t=3000; if(t==4)t=2000; a=t*n; printf("%d\n",a); } return 0; }
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> using namespace std; int main() { for(int i=0 ; i<4 ; ++i){ int t,n; cin >> t >> n; if(t==1){ cout << 6000*n << endl; }else if(t==2){ cout << 4000*n << endl; }else if(t==3){ cout << 3000*n << endl; }else{ cout << 2000*n << endl; } } return 0; }
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
python3
for i in range(4): ti,ni=map(int,input().split()) if ti==1: print(ni*6000) if ti==2: print(ni*4000) if ti==3: print(ni*3000) if ti==4: print(ni*2000)
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<cstdio> int p[4]={6000,4000,3000,2000}; int main(void){ int t,n; for(int i=0;i<4;i++){ scanf("%d%d",&t,&n); printf("%d\n",p[t-1]*n); } return 0; }
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<cstdio> int main(){ int t,n,data[4] = {6000,4000,3000,2000}; for(int i=0;i<4;i++){ scanf("%d %d",&t,&n); printf("%d\n",data[t-1]*n); } return 0; }
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include <iostream> using namespace std; int main() { int t[5] = {0, 6000, 4000, 3000, 2000}; for (int i = 0; i < 4; i++){ int n, a; cin >> a >> n; cout << t[a] * n << endl; } return 0; }
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
python3
# coding: utf-8 # Your code here! for i in range(4): t,n=map(int,input().split()) K = int() if t==1: K = 6000*n elif t==2: K = 4000*n elif t==3: K = 3000*n else: K = 2000*n print(K)
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
python3
for i in range(4): t,n = map(int,input().split()) if t==1: kingaku=6000 elif t==2: kingaku=4000 elif t==3: kingaku=3000 elif t==4: kingaku=2000 print(n*kingaku)
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
python3
ticket_price = [0, 6000, 4000, 3000, 2000] if __name__ == "__main__": for i in range(4): sales = list(map(int, input().split())) print("{0}".format(ticket_price[sales[0]] * sales[1]))
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
python3
p = (0, 6000, 4000, 3000, 2000) for i in range (4): a, n = map(int, input().split()) print(p[a] * n)
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
python3
for i in range(4): t,n=map(int,input().split()) if t==1: x=6000 elif t==2: x=4000 elif t==3: x=3000 elif t==4: x=2000 print(str(x*n))
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<stdio.h> int main() { int i; int n; int prices[] = {6000, 4000, 3000, 2000}; for (i=0; i<4; i++) { int ind; unsigned long long int times; scanf("%d %llu", &ind, &times); printf("%llu\n", prices[ind-1] * times); } }
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> #include<cstdio> using namespace std; int main(){ int a,b; for(int i=0;i<4;i++){ cin>>a>>b; if(a==1)cout<<b*6000<<endl; if(a==2)cout<<b*4000<<endl; if(a==3)cout<<b*3000<<endl; if(a==4)cout<<b*2000<<endl; }return 0; }
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); for(int i=0; i<4; i++){ int a = sc.nextInt(); int b = sc.nextInt(); switch(a){ case 1: System.out.println(b*6000); break; case 2: System.out.println(b*4000); break; case 3: System.out.println(b*3000); break; case 4: System.out.println(b*2000); break; } } } }
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table. input Input data is given in the following format. t1 n1 t2 n2 t3 n3 t4 n4 The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values ​​for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4. output Output the sales amount for each line. Example Input 3 10 1 4 4 1 2 5 Output 30000 24000 2000 20000
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [], "output": [] }
CORRECT
cpp
#include<iostream> using namespace std; int main(){ int t, n; int p[4] = {6000, 4000, 3000, 2000}; for(int i = 0; i < 4; i++){ cin >> t >> n; cout << p[t-1]*n << endl; } return 0; }