QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#419081 | #7697. Impartial Strings | haze# | WA | 0ms | 3752kb | C++23 | 1.5kb | 2024-05-23 17:39:51 | 2024-05-23 17:39:53 |
Judging History
answer
/*
Author: Haze
2024/5/23
*/
#include <bits/stdc++.h>
#define irep(i, l, r) for(int i = (l); i <= (r); ++ i)
#define drep(i, r, l) for(int i = (r); i >= (l); -- i)
#define IOS ios::sync_with_stdio(false), cin.tie(nullptr);
using namespace std;
typedef long long ll;
inline ll readL() {
ll s = 0;
bool fl = false;
char ch = (char) getchar();
while (!isdigit(ch)) {
if (ch == '-')fl = true;
ch = (char) getchar();
}
while (isdigit(ch)) {
s = s * 10 + (ch ^ 48);
ch = (char) getchar();
}
return fl ? -s : s;
}
inline int read() {
return (int) (readL());
}
const int mod = 1000000000 + 7;
const int itinf = 1000000999;
const ll llinf = 2e18;
const int N = 500099;
void solve() {
string s, t, w;
cin >> s >> t >> w;
if(t == w){
cout << 1 << '\n';
return;
}
int ok = 2;
if(s.size() != w.size()){
cout << 0 << endl;
return;
}
int n = t.size();
irep(i, 0, n - 1){
if(t[i] != w[(i + 1) % n])
{
ok --;
break;
}
}
irep(i, 0, n - 1){
if(w[i] != t[(i + 1) % n])
{
ok --;
break;
}
}
set<char>cc;
for(auto c : t)cc.insert(c);
for(auto c : w)cc.insert(c);
if(ok and cc.size() == s.length() || t == w)cout << 1 << '\n';
else cout << 0 << '\n';
}
int main() {
// IOS
int T = read();
while (T--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3752kb
input:
3 ab ab ba abc ab ba cz cczz zzcc
output:
1 0 0
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3580kb
input:
7 d d d d dd d d d dd z zzzzzzzzzzzz zzz a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
output:
1 0 0 0 1 0 0
result:
wrong answer 2nd lines differ - expected: '1', found: '0'