QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#277179 | #7894. Many Many Heads | SSH# | Compile Error | / | / | C++20 | 1.4kb | 2023-12-06 16:04:38 | 2023-12-06 16:04:38 |
Judging History
你现在查看的是最新测评结果
- [2023-12-06 19:13:14]
- hack成功,自动添加数据
- (//qoj.ac/hack/490)
- [2023-12-06 16:04:38]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-12-06 16:04:38]
- 提交
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve();
signed main() {
cin.sync_with_stdio(0);
cin.tie(0);
int T = 1;
cin >> T;
while (T--) {
solve();
}
return 0;
}
int sum;
void solve() {
string s;
cin >> s;
sum+=s.size();
assert(sum<=1000000)
string s1;
for (int i = 0; s[i]; i++) {
if (s[i] == ')' || s[i] == '(') s1 = s1 + '1';
else s1 = s1 + '0';
}
int pre = -1;
for (int i = 1; i < s1.size(); i++) {
if (s1[i] == s1[i - 1]) {
pre = i - 1;
break;
}
}
int d=pre+1;
// cout<<d<<"\n";
if (d*2 > s1.size()) {
cout << "No\n";
return;
}
string ss = s1.substr(pre + 1, d);
string ss1 = s1.substr(0, d);
reverse(ss.begin(), ss.end());
// cout<<ss<<" "<<ss1<<"\n";
if (ss == ss1 && s1[d*2]!=s1[d*2-1]) {
int len = s1.size() - d*2;
if(len==0) {
cout<<"Yes\n";
return;
}
// cout<<len<<"\n";
for (int i = d*2+1; i < s1.size(); i++) {
if (s1[i] == s1[i - 1]) {
pre = i - 1;
break;
}
}
int d1=pre-d*2+1;
if ((d+d1)*2 != s1.size()) {
cout << "No\n";
return;
}
len=pre-d*2+1;
ss = s1.substr(d*2, len);
ss1 = s1.substr(d*2 + len, len);
reverse(ss.begin(), ss.end());
// cout<<ss<<" "<<ss1<<"\n";
if (ss == ss1) {
cout << "Yes\n";
} else {
cout << "No\n";
}
} else {
cout << "No\n";
}
}
詳細信息
answer.code: In function ‘void solve()’: answer.code:22:9: error: expected ‘;’ before ‘string’ 22 | string s1; | ^~~~~~ answer.code:24:49: error: ‘s1’ was not declared in this scope; did you mean ‘s’? 24 | if (s[i] == ')' || s[i] == '(') s1 = s1 + '1'; | ^~ | s answer.code:25:22: error: ‘s1’ was not declared in this scope; did you mean ‘s’? 25 | else s1 = s1 + '0'; | ^~ | s answer.code:28:29: error: ‘s1’ was not declared in this scope; did you mean ‘s’? 28 | for (int i = 1; i < s1.size(); i++) { | ^~ | s answer.code:36:19: error: ‘s1’ was not declared in this scope; did you mean ‘s’? 36 | if (d*2 > s1.size()) { | ^~ | s answer.code:40:21: error: ‘s1’ was not declared in this scope; did you mean ‘ss’? 40 | string ss = s1.substr(pre + 1, d); | ^~ | ss