QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#261650 | #7692. Prof. Fumblemore and the Collatz Conjecture | WA_automaton | AC ✓ | 1ms | 3520kb | C++17 | 1.9kb | 2023-11-23 06:38:57 | 2023-11-23 06:38:57 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
void debug() {std::cerr << "\n";}
template<class T, class... OtherArgs>
void debug(T &&var, OtherArgs &&... args) {
std::cerr << std::forward<T>(var) << " ";
debug(std::forward<OtherArgs>(args)...);
}
#define SZ(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
const int N = 1010, M = 10000010;
const int P = 998244353;
LL powmod(LL a, LL b, LL p = P) {LL res = 1 % p; a %= p; assert(b >= 0); for(; b; b >>= 1) { if (b & 1) res = res * a % p; a = a * a % p; } return res; }
int n, m;
void solve() {
string s;
cin >> s;
n = s.size();
for (int i = 1; i < n; i++) {
if (s[i] == 'O' && s[i - 1] == 'O') {
cout << "INVALID\n";
return;
}
}
if (s.back() == 'E') {
cout << "INVALID\n";
return;
}
__int128 ans = 1e18;
for (int now = 8; now <= 1ll << 47; now <<= 1) {
__int128 x = now;
for (int i = n - 1; ~i; i--) {
if (s[i] == 'O') {
if ((x - 1) % 3) {
x = -1;
break;
}
x = (x - 1) / 3;
} else {
if ((x & (x - 1)) == 0) {
x = -1;
break;
}
x *= 2;
}
}
if (x != -1) {
ans = min(ans, x);
}
}
cout << (int)ans << '\n';
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(20);
int _ = 1;
// cin >> _;
while (_--) solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3472kb
input:
EEOEO
output:
12
result:
ok single line: '12'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3476kb
input:
EEOOEO
output:
INVALID
result:
ok single line: 'INVALID'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3448kb
input:
OEOEOEOEOEOEOEEEEEEOEEEOEEEOEEEOEOEEOEEEO
output:
383
result:
ok single line: '383'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3488kb
input:
OEOEEEEEOEOEEEEOEEEEOEOEOEEOEEEO
output:
931
result:
ok single line: '931'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3516kb
input:
OEEOEEOEEOEOEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO
output:
641
result:
ok single line: '641'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3360kb
input:
OEOEEOEEOEEOEEOEEEEOEEEOEOEOEEEEEO
output:
683
result:
ok single line: '683'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3424kb
input:
OEEOEEEOEOEEEEOEEEEOEOEOEEOEEEO
output:
465
result:
ok single line: '465'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3364kb
input:
OEEOEEOEOEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO
output:
481
result:
ok single line: '481'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3424kb
input:
OEEOEOEO
output:
201
result:
ok single line: '201'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3436kb
input:
OEEEEOEEOEOEEEOEOEEOEEEO
output:
133
result:
ok single line: '133'
Test #11:
score: 0
Accepted
time: 1ms
memory: 3472kb
input:
OEOEOEOEEOEEEEEEEEEEOEOEOEEOEEEO
output:
943
result:
ok single line: '943'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3412kb
input:
OEEEOEEO
output:
301
result:
ok single line: '301'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3416kb
input:
OEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO
output:
407
result:
ok single line: '407'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3476kb
input:
OEOEOEOEOEOEEOEEEEOEEEOEEEOEEEOEOEEOEEEO
output:
191
result:
ok single line: '191'
Test #15:
score: 0
Accepted
time: 1ms
memory: 3468kb
input:
OEEEOEO
output:
605
result:
ok single line: '605'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3468kb
input:
OEOEOEOEEOEEEEOEEEOEEEOEEEOEOEEOEEEO
output:
431
result:
ok single line: '431'
Test #17:
score: 0
Accepted
time: 1ms
memory: 3448kb
input:
OEOEEEOEEEOEOEOEEEOEEEEOEOEEEOEOEEOEEEO
output:
563
result:
ok single line: '563'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3464kb
input:
OEEOEEEEEOEEOEEEO
output:
241
result:
ok single line: '241'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3364kb
input:
OEEEOEEEEOEOEEEOEOEEOEEEO
output:
269
result:
ok single line: '269'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
EEOEOEOEEOEEEEOEOEEOEEOEEEEOEOEOEEOEEEO
output:
540
result:
ok single line: '540'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3452kb
input:
OEOEOEOEOEOEEEEEEOEEEOEEEOEEEOEOEEOEEEO
output:
575
result:
ok single line: '575'
Test #22:
score: 0
Accepted
time: 1ms
memory: 3360kb
input:
EEOEEOEOEEEEEOEOEOEEEEEO
output:
868
result:
ok single line: '868'
Test #23:
score: 0
Accepted
time: 1ms
memory: 3436kb
input:
OEOEOEO
output:
26512143
result:
ok single line: '26512143'
Test #24:
score: 0
Accepted
time: 0ms
memory: 3360kb
input:
OEOEOEEO
output:
13256071
result:
ok single line: '13256071'
Test #25:
score: 0
Accepted
time: 0ms
memory: 3476kb
input:
EEO
output:
20
result:
ok single line: '20'
Test #26:
score: 0
Accepted
time: 1ms
memory: 3440kb
input:
EOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEE
output:
INVALID
result:
ok single line: 'INVALID'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEO
output:
43980465111040
result:
ok single line: '43980465111040'
Test #28:
score: 0
Accepted
time: 1ms
memory: 3460kb
input:
EEEEEEEEEEOEEEOEEEEOEOEEOEEEEEOEEEEEEEOEEOEEEEEEEO
output:
7321693729792
result:
ok single line: '7321693729792'
Test #29:
score: 0
Accepted
time: 1ms
memory: 3416kb
input:
EEEOEEEOEEOEEEEEOEEEEEEEOEEEEEEEEEEEEEEEEOEEEEEO
output:
1028529777000
result:
ok single line: '1028529777000'