QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#876093 | #7692. Prof. Fumblemore and the Collatz Conjecture | Teapot# | AC ✓ | 1ms | 3968kb | C++20 | 2.3kb | 2025-01-30 17:03:34 | 2025-01-30 17:03:35 |
Judging History
answer
/** gnu specific **/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/** contains everything I need in std **/
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(S) ((int)S.size())
#define FOR(i, st_, n) for(int i = st_; i < n; ++i)
#define RFOR(i, n, end_) for(int i = (n)-1; i >= end_; --i)
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ull, ull> pull;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
string s;
cin >> s;
ll n = sz(s);
bool t = true;
if(s[n-1] == 'E')
t = false;
FOR(i,1,n)
if(s[i] == s[i-1] && s[i] == 'O')
t = false;
FOR(i,0,n)
if(s[i] != 'O' && s[i] != 'E')
t = false;
if(!t)
{
cout << "INVALID" << endl;
return 0;
}
ll cur = 0;
t = true;
set<ll> tw;
FOR(i,0,n)
{
tw.insert(pow(2ll,i));
}
ll res = -1;
FOR(j,2,47)
{
t = true;
cur = pow(2,j);
RFOR(i,n,0)
{
if(s[i] == 'E')
cur*=2;
else
{
if((cur-1)%3 != 0)
{
t = false;
break;
}
else
cur = (cur-1)/3;
}
if(tw.find(cur) != tw.end())
t = false;
if(cur <= 0)
t = false;
}
if(t){
if(res == -1)
res = cur;
else
res = min(res,cur);
}
}
if(res != -1)
cout << res << endl;
else
while(true)
res++;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3840kb
input:
EEOEO
output:
12
result:
ok single line: '12'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
EEOOEO
output:
INVALID
result:
ok single line: 'INVALID'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
OEOEOEOEOEOEOEEEEEEOEEEOEEEOEEEOEOEEOEEEO
output:
383
result:
ok single line: '383'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
OEOEEEEEOEOEEEEOEEEEOEOEOEEOEEEO
output:
931
result:
ok single line: '931'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
OEEOEEOEEOEOEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO
output:
641
result:
ok single line: '641'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
OEOEEOEEOEEOEEOEEEEOEEEOEOEOEEEEEO
output:
683
result:
ok single line: '683'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
OEEOEEEOEOEEEEOEEEEOEOEOEEOEEEO
output:
465
result:
ok single line: '465'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3968kb
input:
OEEOEEOEOEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO
output:
481
result:
ok single line: '481'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
OEEOEOEO
output:
201
result:
ok single line: '201'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
OEEEEOEEOEOEEEOEOEEOEEEO
output:
133
result:
ok single line: '133'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
OEOEOEOEEOEEEEEEEEEEOEOEOEEOEEEO
output:
943
result:
ok single line: '943'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
OEEEOEEO
output:
301
result:
ok single line: '301'
Test #13:
score: 0
Accepted
time: 1ms
memory: 3968kb
input:
OEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO
output:
407
result:
ok single line: '407'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3968kb
input:
OEOEOEOEOEOEEOEEEEOEEEOEEEOEEEOEOEEOEEEO
output:
191
result:
ok single line: '191'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
OEEEOEO
output:
605
result:
ok single line: '605'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
OEOEOEOEEOEEEEOEEEOEEEOEEEOEOEEOEEEO
output:
431
result:
ok single line: '431'
Test #17:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
OEOEEEOEEEOEOEOEEEOEEEEOEOEEEOEOEEOEEEO
output:
563
result:
ok single line: '563'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
OEEOEEEEEOEEOEEEO
output:
241
result:
ok single line: '241'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
OEEEOEEEEOEOEEEOEOEEOEEEO
output:
269
result:
ok single line: '269'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
EEOEOEOEEOEEEEOEOEEOEEOEEEEOEOEOEEOEEEO
output:
540
result:
ok single line: '540'
Test #21:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
OEOEOEOEOEOEEEEEEOEEEOEEEOEEEOEOEEOEEEO
output:
575
result:
ok single line: '575'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
EEOEEOEOEEEEEOEOEOEEEEEO
output:
868
result:
ok single line: '868'
Test #23:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
OEOEOEO
output:
26512143
result:
ok single line: '26512143'
Test #24:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
OEOEOEEO
output:
13256071
result:
ok single line: '13256071'
Test #25:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
EEO
output:
20
result:
ok single line: '20'
Test #26:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
EOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEE
output:
INVALID
result:
ok single line: 'INVALID'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEO
output:
43980465111040
result:
ok single line: '43980465111040'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
EEEEEEEEEEOEEEOEEEEOEOEEOEEEEEOEEEEEEEOEEOEEEEEEEO
output:
7321693729792
result:
ok single line: '7321693729792'
Test #29:
score: 0
Accepted
time: 0ms
memory: 3968kb
input:
EEEOEEEOEEOEEEEEOEEEEEEEOEEEEEEEEEEEEEEEEOEEEEEO
output:
1028529777000
result:
ok single line: '1028529777000'