QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#331953 | #7695. Double Up | cry# | WA | 0ms | 3876kb | C++20 | 919b | 2024-02-19 00:39:32 | 2024-02-19 00:39:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
string s; cin >> s;
int n = s.size();
for(int i = 0; i < n - 1; i++){
if(s[i] == 'O' && s[i + 1] == 'O'){
cout << "INVALID" << endl;
return 0;
}
}
if(s.back() != 'O'){
cout << "INVALID" << endl;
return 0;
}
for(ll start = 3; ; start += 2){
ll res = start;
bool ok = true;
for(int i = n - 2; i >= 0; i--){
if(s[i] == 'E'){
res *= 2;
}
else{
res--;
if(res % 3 != 0){
ok = false;
break;
}
res /= 3;
}
if(s[i] == 'E' && res % 2 == 1){
ok = false;
break;
}
if(s[i] == 'O' && res % 2 == 0){
ok = false;
break;
}
if(__builtin_popcountll(res) == 1){
ok = false;
break;
}
}
if(ok){
cout << res << "\n";
break;
}
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3876kb
input:
5 4 2 2 1 8
output:
INVALID
result:
wrong answer 1st lines differ - expected: '16', found: 'INVALID'