text stringlengths 49 983k |
|---|
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include... |
#include<iostream>
#include<string>
using namespace std;
bool check(string s,int n) {
if (s.size() <= n)return true;
return false;
}
void solve() {
string s; cin >> s;
int n = 0;
if (s[n] == '>') {
n++;
if (check(s, n));
else if (s[n] == '\'') {
n++;
int cnt = 0;
while (s[n] == '=' && !check(s, n)) ... |
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;
typed... |
#include <iostream>
#include <string>
using namespace std;
bool kind_a(string str){
if(str[0] != '>' || str[1] != '\'' || str[str.size()-1] != '~'){
return false;
}
string su = str.substr(2, str.size()-3);
if(su.size()<3)
return false;
for(int i=0; i<su.size(); ++i){
int j = su.size()-1-i;
... |
// 2011/10/02 Tazoe
#include <iostream>
#include <string>
using namespace std;
int main()
{
int n;
cin >> n;
for(int i=0; i<n; i++){
string str;
cin >> str;
if(str[0]!='>'){
cout << "NA" << endl;
continue;
}
if(str[1]=='\''){
int N = 0;
int I = 2;
while(str[I]=='='){
N++;
I++;
... |
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n,f,i,m;
string s;
cin>>n;
while(n-->0){
cin>>s;
f=0;
if(s[0]=='>' && s[1]=='\''){
m=s.find('#');
if(m!=string::npos){
for(i=1;s[m-i]==s[m+i];)i++;
if(i>1 && m-i==1 && m+i==s.size()-1 && s[m+i]=='~')f=1;
}... |
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#define int long long
#define rep(i, n) for (int i=0; i<n; i++)
#define REP(n) rep(i, n)
using namespace std;
int n;
string snake, head, tail, body;
signed main()
{
cin >> n;
REP(n)
{
cin >> snake;
if (snak... |
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
enum { A, B, NA };
int f(string s){
if(s.size() < 6) return NA;
if(s.substr(0,2)==">'"){
size_t i=2;
while(i<s.size() && s[i]=='=') i++;
if(i==2 || i==s.size() || s[i]!='#') return NA;
size_t j=i+1;
... |
#include <iostream>
#include <string>
using namespace std;
int main()
{
int n;
cin >> n;
for(int i=0;i<n;i++){
bool a=false,b=false;
string str;
cin >> str;
if(str[0] == '>' && str[1] == '\'' && str.size()%2==0 && str.size() >= 6){a = true;}
if(str[0] == '>' && str[1] == '^' && str.size()%2==0 && str.size... |
#include<iostream>
#include<string>
using namespace std;
int checkA(string);
int checkB(string);
int main(){
int i, n;
string snake;
cin >> n;
for(i=0; i<n; ++i){
cin >> snake;
if(checkA(snake) == 1)
cout << "A" << endl;
else if(checkB(snake) == 1)
cout << "B" << endl;
else
... |
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstr... |
#include<bits/stdc++.h>
using namespace std;
int main(){
string str;
int n; cin >> n;
while(n--){
cin >> str;
int idx = 2;
int cnt = 0;
bool flg = true;
if(str[0] == '>' && str[1] == 39){
bool used = false;
while(idx < str.size() && str[idx] == '=') {
used = true;
cnt++;
idx++;... |
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int main(void) {
cin >> n;
for (int k = 0; k < n; k++) {
cin >> s;
bool f = true;
if (s[0] == '>' && s[1] == '\'') {
int c = 0;
int i;
for (i = 2; s[i] == '='; i++)
c++;
if (c && s[i] == '#') {
for (i += 1; s[i] == '='; i++)
... |
#include<stdio.h>
#include<string.h>
int n,len;
char t[300];
int checkA(){
if(t[len-1]!='~')return 0;
int i=2,j=len-2;
while(i<j){
if(t[i]!='=')return 0;
if(t[j]!='=')return 0;
i++;
j--;
}
if(t[i]=='#')return 1;
else return 0;
}
int checkB(){
if(t[len-2]!='~')return 0;
if(t[len-1]... |
#include <string>
#include <iostream>
using namespace std;
int n; string s;
int check() {
if(s.size() < 6) return 0;
if(s[0] != '>') return 0;
if(s[1] == '\'') {
int cnt = 0, cntp = 0;
for(int i = 2; i < s.size() - 1; i++) {
if(s[i] != '=') break;
cnt++; cntp++;
}
if(s[2 + cnt] != '#') return 0;
for(... |
#include <stdio.h>
bool checkA(char *p){
int eqCnt=0;
if (*p++!='>') return false;
if (*p++!='\'') return false;
if (*p!='=') return false;
while (*p++=='=') eqCnt++;
p--;
if (*p++!='#') return false;
while (*p++=='=') eqCnt--;
p--;
if (eqCnt!=0) return false;
if (*p++!... |
#include <iostream>
#include <string>
using namespace std;
int main(){
int n;
string s;
cin >> n;
for(int i = 0;i < n;i++){
cin >> s;
if(s.substr(0,2) == ">\'"){
if(s[s.length() - 1] != '~') cout << "NA" << endl;
else {
int cnt = 0,pos = 2;
bool flag = true;
for(;;pos++){
if(s[pos] == '#... |
#include <bits/stdc++.h>
using namespace std;
bool isA(string s) {
int cnt1 = 0;
for (int i = 2; i < s.size(); ++i) {
if (s[i] == '=') {
++cnt1;
} else if (s[i] == '#') {
if (cnt1 == 0) return false;
break;
} else {
return false;
}
if (i == s.size() - 1) return false;
... |
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
bool check_A( string &S )
{
auto sz = S.size();
//size ??? 6 ??\?????????????????? false
if( sz < 6 )
{
return 0;
}
//?????????[>'=], ??... |
#include <iostream>
using namespace std;
/*s[i]ツつゥツづァツ督ッツつカツ閉カツ篠堋つェツ連ツ堕アツつオツづつ「ツづゥツ青板づーツ陛板つキ*/
int seqlen(string &s,int i){
char c = s[i];
int ret=0;
while(s[i++]==c)ret++;
return ret;
}
int main(){
int n;
int flag = 0;
string s;
cin >> n;
while(n--){
flag = 0;
cin >> s;
/*A*/
if(s[0]=='>' && s[1]==3... |
#include <iostream>
#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
const int INF = 10000000;
using namespace std;
typedef long long ll;
/** Problem0139 : Snakes **/
int main()
{
int n;
string s;
cin >> n;
rep(k, n) ... |
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
string s;
for (int i=0; i<n; ++i) {
cin >> s;
int m = s.size();
string res = "NA";
if (s.size() < 6 || s.size() % 2 == 1) {
// pass
} else if (s... |
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>
#define f first
#define s second
#define mp make_pair
#define REP(i,n) for(int i... |
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pip;
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n, len;
string s;
int checkA() {
int i=2, j=len-2;
while(i<j)... |
#include <iostream>
#include <string>
using namespace std;
void jagdeA( const string& str )
{
int count = 0;
int i;
for( i = 2;i < str.size();i++ ){
if( str[i] == '=' ) count++;
else if( count && str[i] == '#' ) break;
else{
cout << "NA" << endl;
return;
}
}
if( i == str.size() ){
cout << "NA" ... |
#include<iostream>
#include<string>
using namespace std ;
string S ;
int funcA(){
int cnt = 0 , i ;
for( i=2 ; i<S.size() ; i++ ){
if( S[i] == '=' ) cnt++ ;
else if( S[i] == '#' ) break ;
else return -1 ;
}
if( cnt == 0 ) return -1 ;
for( i++ ; i<S.size() ; i++ ){
if( S[i] == '=' ) cnt-- ;
else if( S[i... |
#include <iostream>
#include <string>
using namespace std;
bool isA(const string& s){
if( s.size() >= 1 && s[0] != '>' ) return false;
if( s.size() >= 2 && s[1] != '\'' ) return false;
int cnt1 = 0, cnt2 = 0;
for(int i=2, j=0 ; i < s.size()-1 ; i++ ){
if( s[i] == '=' ){
j? cnt1++ : cnt2++;
}else if( s[i] ... |
#include <cstdio>
#include <regex.h>
#include <cstring>
int main() {
int n;
regex_t regst[2];
regmatch_t match[3];
const char *pattern[] = {"^>'(=+)#(=+)~$", "^>\\^(Q=)+~~$"};
const char *type_label[] = {"A", "B", "NA"};
int type;
char snake[201];
scanf("%d", &n);
for (int x=0; x<n; x++) {
sca... |
#include<stdio.h>
#include<string.h>
bool checkA(char st[1001]){
int len = strlen(st);
if(len<4)return false;
if(st[len-1]!='~')return false;
if(len%2 == 1)return false;
st[len/2-1] = '=';
for(int i = 0; i < len-1; i++){
if(st[i] !='=')return false;
}
return true;
}
bool checkB(char st[1001]){
if(strlen(s... |
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <c... |
#include<iostream>
#include<string>
using namespace std;
int main(){
long n,f,i,j,k,m;
string s;
cin>>n;
for(i=0;i<n;i++){
cin>>s;
if(s.substr(0,2)==">'"){
if(s.substr(2,1)!="="){f=2;goto E;}
j=s.find_first_not_of('=',3);
m=j-2;
if(s.substr(j,1)!="#"){f=2;goto E;}
k=s.find_first_not_of('=',j+1);
if(k-j-1!=m){f=2;goto E... |
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#de... |
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
while(n--)
{
string str;
string kp;
string set;
int flag=0;
int count=0;
int count_b=0;
int i=0;
cin >> str;
for(i=0;i<2;i++)kp+=str[i]++;
if(kp==">'")
{
while(str[i]!='#')
{
if(str[i]=='=')count++;
... |
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n,f,i,m;
string s;
cin>>n;
while(n-->0){
cin>>s;
f=0;
if(s[0]+s[1]=='>'+'\''){
m=s.find('#');
if(m!=string::npos){
for(i=1;s[m-i]==s[m+i];)i++;
if(i>1 && m-i==1 && m+i==s.size()-1 && s[m+i]=='~')f=1;
}
... |
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#define __clock__
#else
#pragma GCC optimize("Ofast")
#endif
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;
using PII = pair<ll, ll>;
// tourist set
template <typename A, typenam... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int T;
cin >> T;
while(T--) {
string s;
cin >> s;
if(s[0]!='>'||s.size()<=3) cout << "NA" << endl;
else if(s[1]=='\'') {
if(s[s.size()-1]!='~'||s.size()%2) {
cout << "NA" << endl;
goto next;
}
s=s.substr(... |
#include<iostream>
#include<string>
using namespace std;
int main()
{
string s, r;
int n,i;
bool b;
cin>>n;
while(n--)
{
cin>>s;
r = "NA";
if(s.size() > 5 && (s.size()&1)==0 && s[0]=='>')
{
if(s[1]=='\'')
{
if(s[s.size()-1]=='~' && s[s.size()/2]=='#')
{
b=true;
for(i=2;i<s.size()/2... |
#include<iostream>
#include<string>
#include<sstream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
int n;
cin>>n;
for(int i=0;i<n;++i){
string line;
cin>>line;
string sol = "NA";
if(line.find('#')!=string::npos){
bool flag = false;
string a = "";
string b = ""... |
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
int Tc; string s;
while(cin>>Tc) {
while(Tc--) {
cin >> s;
int const N = s.size();
bool NA = 0;
bool isA;
if(s[0] != '>') NA = 1;
if(s[1] == '\'') {
if(s[2] != '=') NA = 1;
for(int... |
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int ma... |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FR first
#define SC second
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) fo... |
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()
const double eps = 1e-10;
const double pi = acos(-1.0);
const double inf = (int)1e8;
int main(){
int n; cin >> n;
rep(q,... |
#include <iostream>
#include <string>
using namespace std;
int main(){
int n;
cin >> n;
for(int q=0;q<n;q++) {
string str;
cin >> str;
if(str[0] != '>') {
cout <<"NA"<<endl;
continue;
} else if(str[1] != '\''&& str[1] != '^') {
cout << "NA" << endl;
continue;
}
... |
#include<iostream>
#include<string>
using namespace std;
int check(string str)
{
if(str[0] != '>'){ return -1; }
if(str[1] != '\'' && str[1] != '^'){ return -1; }
if(str[2] == '='){
if(str[str.size()-1] != '~' || str[str.size()-2] != '='){ return -1; }
int i=3,cnt1=1,cnt2=0;
while(str[i] != '#'){
... |
#include<iostream>
#include<string>
using namespace std;
int isfa(string);
int isfb(string);
int main(){
int n,fa,fb;
string str;
cin >> n;
for(int i = 0;i < n;i++){
cin >> str;
if(str.size()>5){
fa = isfa(str);
fb = isfb(str);
}else fa=fb=0;
if(fa == 1)
cout << "A" << end... |
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
bool check_A(string str){
if(str.size() < 6 || str.size() % 2 == 1){
return false;
}
if(str.substr(0, 2) != ">'"){
return false;
}
int count = 0;
for(int i = 2; i < (str.size() - 4) / 2 + 2; i++){
if(str[i] !=... |
#include <iostream>
using namespace std;
typedef string::iterator S;
string ss;
string snakeA(S it){
int count = 0;
for(;it!=ss.end()&&*it=='=';it++,count++);
if(!count) return "NA";
if(it==ss.end()||*it!='#') return "NA";
it++;
for(;it!=ss.end()&&*it=='=';it++,count--);
if(it==ss.end()||*... |
#include <iostream>
#include <cstdio>
#include <string.h>
using namespace std;
int checksnake(string, int);
int main(void) {
int n, len;
char snake[200];
int type;
cin >> n;
for(int i = 0 ; i < n ; i++) {
scanf("%s", snake);
len = strlen(snake);
type = checksnake(snake, len);
if(type == 1) co... |
#include <iostream>
#include <string>
using namespace std;
bool isa(string s) {
int pos = 2,cnt = 0;
if(s[pos] != '=') return false;
while(s[pos] == '=') pos++,cnt++;
if(s[pos] != '#') return false;
pos++;
for(int i=0; i<cnt; ++i) {
if(s[pos+i] != '=') return false;
}
pos += cn... |
#include<iostream>
using namespace std;
int main()
{
int n;
for(cin>>n;n--;)
{
string s;
cin>>s;
string ans="NA";
if(s.substr(0,2)==">'" &&s[s.size()-1]=='~')
{
string tmp=s.substr(2,s.size()-3);
// cout<<tmp<<endl;
if(tmp.size()%2!=0
&& tmp.size()>1
&& tm... |
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
bool asnake(string s){
int n=s.size();
if(n%2 || n<6)return false;
string com=">\'";
rep(i,(n-4)/2)com+='=';
com+='#';
rep(i,(n-4)/2)com+='=';
com+='~';
if(s==com)return true;
else re... |
#include <iostream>
#include <string>
using namespace std;
int main(void){
int i,j,n,a;
string s,ans;
cin >> n;
for(i = 0 ; i < n ; i++ ){
cin >> s;
ans = "NA";
if( s[0] == '>'){
if( s[1] == '\''){
a = 2;
int cnt1 = 0,cnt2 = 0;
if( s[a] == '='){
while( s[a] == '='){
... |
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;
#define reep(i,a,b) for(int i=(a);i<(b);++... |
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
using namespace std;
type... |
#include <iostream>
using namespace std;
bool chk_a(const string s)
{
bool c = true;
int f, b;
f = b = 0;
for (int i = 0; i < s.size(); i++) {
if (s[i] != '=' && s[i] != '#')
return false;
if (c && s[i] == '#')
c = false;
else if (s[i] == '=' && c)
... |
#include <iostream>
#include <string>
using namespace std;
int main()
{
const string Type[] = {"A", "B", "NA"};
int n;
while (cin >> n) {
for (int i = 0; i < n; ++i) {
string snake;
cin >> snake;
int ans = 2;
int length = static_cast<int>(snake.size());
if (snake[0] == '>' && ... |
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
string kaga(string s,int num){
string san;
for(int i=0;i<num;i++)san+=s;
return san;
}
void check(string s){
for(int i=1;i<99;i++){
string a,b;
a=">'"+kaga("=",i)+'#'+kaga("=",i)+'~';
b=">^"+kaga("Q=",i)+"~~";
if(a==s){
cou... |
#include <iostream>
//CÓ¶ðÁ·Ö
int clear(std::string s, std::string f){
int pos;
while(pos = s.find(f), pos != std::string::npos)
s.replace(pos,f.size(),"");
if(s == "")return 1;
return 0;
}
int main(){
int n;
std::cin >> n;
while(n--){
std::string sn, res = "";
std::cin >> sn;
//Type A
//... |
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int check( string S )
{
//A
if( S[ 0 ] == '>' && S[ 1 ] == '\'' && S[ S.size() - 1 ... |
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n,i,j;
string str;
cin >> n;
for(i=0;i<n;i++)
{
cin >> str;
if(str[0]=='>')
{
if(str[1]=='\'')
{
int num=0;
for(j=2;j<str.size();j++)
{
if(str[j]=='=')
num++;
else if(num>0 && str[j]=='#')
... |
#include<iostream>
#include<string>
using namespace std;
int main(){
int n,j,fa,fb,acount,acount2,i;
string data;
cin >> n;
getline(cin,data);
for(j = 0; j < n; j++){
fa = 0;
fb = 0;
acount = acount2 = 0;
getline(cin,data);
if(data.length() < 6)
data = "OOHAZURE";
if(data[... |
//11
#include<string>
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
while(n--){
string s;
cin>>s;
if(s.size()>=6&&s==">'"+string((s.size()-4)/2,'=')+'#'+string((s.size()-4)/2,'=')+'~'){
cout<<'A'<<endl;
}else{
int r=(s.size()-4)/2;
string b;
while(r--... |
#include<iostream>
#include<string>
using namespace std;
bool isA(string s){
if(s.size() < 6 || s.size() % 2 == 1) return false;
if(s.substr(0,2) != ">\'") return false;
if(s[s.size() - 1] != '~') return false;
int a, b;
for( a = 2, b = s.size() - 2 ; a != b ; a++, b--){
if(s[a] != '=' || s[b] != '=') ... |
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>
#include <math.h>
#include <string.h>
using namespace std;
bool hebi_a(string hebi){
if(!(hebi[0]=='>' && hebi[1]=='\''))return ... |
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# includ... |
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;
typedef... |
#include<iostream>
#include<string>
using namespace std;
int main(){
int f,i,m;
string s;
for(cin>>f;cin>>s;f?puts(f-2?"A":"B"):puts("NA")){
f=0;
for(i=1;s[0]+s[1]==101 & (m=s.find(35))!=string::npos & s[m-i]==s[m+i];)
m-++i-1 | m+i-s.size()+1 | s[m+i]-'~'||(f=1);
for(i=2;s[0]+s[1]==156 & s[i]=... |
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
int main... |
#include <regex>
#include <iostream>
#include <string>
using namespace std;
int main(){
int n;
string s;
smatch m;
for(cin>>n,getline(cin,s);n;n--){
getline(cin,s);
if(regex_match(s,m,regex(">'(=+)#(=+)~"))&&m[1].length()==m[2].length())cout<<'A'<<endl;
else if(regex_match(s,regex(">^(Q=)+~~")))cout<<'B'<<end... |
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>
#include <algorithm>
#include <complex>
#include <list>
#include <map>
#inclu... |
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
int n; scanf("%d", &n);
rep(i, n) {
string s; cin >> s;
if (s.size() < 4 || s.size() % 2 == 1) {
puts("NA");
continue;
}
if (s[0] == '>'&&s[1] == '\''&&s[s.size() - 1] == '~') {
int cnt = 0;
bool flag =... |
#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;
i... |
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <nume... |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int n;
cin>>n;
while(n--){
string s;
cin>>s;
bool f=s[0]=='>';
int l=s.size();
f&=l>5;
if(s[1]=='\''){
int x=0;
int i;
for(i=2;i<l;i++){
if(s[i]=='=') x++;
else{
f&=s[i]=='#';
break;
}... |
#include<iostream>
#include<string>
int main(){int f,i,m;std::string s;for(std::cin>>f;std::cin>>s;f?puts(f-2?"A":"B"):puts("NA")){f=0;for(i=1;s[0]+s[1]==101&(m=s.find(35))!=-1&s[m-i]==s[m+i];)m-++i-1|m+i-s.size()+1|s[m+i]-'~'||(f=1);for(i=2;s[0]+s[1]==156&s[i]==81&s[i+1]==61;)++++i-s.size()+2|s[i]+s[i+1]-252||(f=2);}} |
#include<iostream>
#include<string>
using namespace std;
int main(){
int n;
string s;
cin>>n;
for(int u=0;u<n;u++){
cin>>s;
bool a=true,b=true;
if(s[0]!='>'||s.size()%2!=0||s.size()<6)a=false,b=false;
if(s[1]!='\''||s[s.size()-1]!='~')a=false;
if(s[1]!='^'||s[s.si... |
#include <stdio.h>
#include <string.h>
int main(void) {
int max,data;
int num;
int cut_i;
char hebi[201];
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(heb... |
#include <bits/stdc++.h>
using namespace std;
bool checkA(char* s){
if(s[0] != '>' || s[1] != '\'' || s[2] != '='){
return false;
}
int slen = 0;
while(s[slen+2] == '='){
slen++;
}
if(s[slen+2] != '#'){
return false;
}
for(int i = slen+3; i < slen*2+3;i++){
if(s[i] != '='){
return false;
}
}
ret... |
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#define INF 999999
using namespace std;
int main(){
int N,j;
cin>>N;
while(N--){
int runcnt=0,j;
char S[128000]={0};
cin>>S;
if(S[0]=='>'&&S[1]==39){
int K=0;
... |
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <c... |
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdli... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
bool f(string s) {
int l = 0, r = 0, sz = s.size();
while (r < sz && s[r] == '=') r++;
if (r - l == 0) return false;
if (r < sz && s[r] != '#') return false;
if (s.substr(r + 1, r - l) != string(r - l, '=')) retu... |
#include <iostream>
#include <string>
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] == '\'' && snake.length() >= 6) {
int shape = 0;
for(int i = 2; i < ... |
//Name: Snakes
//Level: 2
//Category: 文字列,オートマトン
//Note:
/**
* AとBは別々に判定する。
*/
#include <iostream>
#include <string>
using namespace std;
bool snakeA(const string &s) {
auto it = begin(s);
int cnt = 0;
if(*it++ != '>') return false;
if(*it++ != '\'') return false;
while(true) {
const c... |
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n;
cin >> n;
for(int D = 0; D < n; ++D){
string s;
cin>>s;
if(s.compare(0,2,">'")== 0){
int bef_eq = 0;
int aft_eq = 0;
int shp = 0;
int pos_shp = 0;
int pos_tld = 0;
for(unsigned int i = 2; i < s.length(); ++i ){... |
#include <iostream>
#include <string>
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
int main()
{
int n; cin >> n;
while (n--) {
string s; cin >> s;
string head = s.substr(0, 2);
bool ok = true;
if (head == ">'") {
int c = 0;
REP... |
#include <iostream>
#include <string>
using namespace std;
string afunc(string str)
{
string res = "NA";
if(str[0] == '#'){
return res;
}
for(int i = 0, j = str.size()-1; i <= j; i++, j--){
if(i == j){
if(str[i] == '#'){
res = "A";
}
} else if(str[i] != '=' || str[j] != '='){
break;
}
}
... |
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {... |
#include <iostream>
int main(){
int n;
std::cin >> n;
while(n--){
std::string sn, res = "";
std::cin >> sn;
//Type A
//ªª>'CKöª~C©Â¨ ̪ªïÅ é
if(sn.substr(0,2) == ">'" &&
sn[sn.size()-1] == '~' && (sn.size()-3) % 2 == 1){
std::string st = sn.substr(2,sn.size()-3);
//¨ Ì... |
#include <iostream>
#include <string>
using namespace std;
bool is_A(string s){
int size = s.size();
if(size < 6) return false;
if(s[0] != '>' || s[1] != '\'') return false;
if(s[size - 1] != '~') return false;
if(s[2] != '=') return false;
int count = 0;
int i = 2;
while(s[i] == '='){ count++; i++; }
if(s[i+... |
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define rep(i, n)for((i) = 0;(i) < (n);++(i))
string solve(string s){
int i = 0, j;
string tmp;
rep(i, 100){
tmp += "=";
if(s == ">'" + tmp + "#" + tmp + "~")return "A";
}
tmp.clear();
rep(i, 100){
tmp += "Q=";
if(s == ">^" + t... |
#include<iostream>
#include<string>
using namespace std;
int main(){
string snake;
int n,len;
cin >> n;
for(int i=0;i<n;i++){
cin >> snake;
len = snake.size();
int ans = -1;
if(snake[0] == '>' && snake[1] == '\''){
int pos = 2;
int turn = 0;
int flag = 0;
int count = 0;... |
#include <iostream>
#include <string>
using namespace std;
void solve()
{
int n;
cin >> n;
while(n--)
{
string snake;
cin >> snake;
if(snake.size() < 4)
{
cout << "NA" << endl;
}
else if(snake[0] == '>' && snake[1] == '\'' && snake[snake.size() - 1] == '~')
{
bool first = true;
int count1 =... |
#include <iostream>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
string s;
int n;
cin >> n;
rep(i,n) {
cin >> s;
int len = s.length();
bool fa = 0, fb = 0;
if(len > 5 && len % 2 == 0) {
fa = 1;
string ns;
... |
#include<iostream>
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(cnt>0&&s[i]=='#')
... |
#include <iostream>
#include <string>
using namespace std;
void printNA() {
cout << "NA" << endl;
}
void judgeB(string s) {
if (s.substr(s.size() - 2, 2) != "~~") {
printNA();
return;
}
if (s.size() <= 4) {
printNA();
return;
}
for (int i = 2; i < s.size() - 2; ... |
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main(void){
int n;
cin >> n;
for(int i=0;i<n;i++){
string str;
cin >> str;
if(str.size()<2)cout << "NA" << endl;
else if(str[0]=='>' && str[1]=='\''){
int j=2;
int l[2]={0,0};
int ck=0;
bool ch[2]={false,true};
whil... |
#include <iostream>
#include <string>
using namespace std;
int n;
string s;
bool checkA(string s) {
if (s.length() < 6) return false;
if (s[0] != '>') return false;
if (s[1] != '\'') return false;
int i;
for (i = 2; i < s.length() && s[i] == '='; i++);
if (i == s.length() || s[i] != '#') return false;
int cn... |
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
void a(){
cout << "NA" << endl;
return;
}
int main(){
int n;
vector<string> sample;
string aaa;
cin >> n;
for(int i=0;i<n;i++){
cin >> aaa;
sample.push_back(aaa);
}
for(unsigned int i=0;i<sample.size();i++... |
#include<iostream>
#include<string>
using namespace std;
int count( string str, string t, int &curr ){
int cnt = 0;
for( ; curr + t.size() - 1 < str.size(); cnt++, curr += t.size() ){
if( str.substr(curr, t.size()) != t ) break;
}
return cnt;
}
bool isA( string str, int curr ){
if ( str.s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.