QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#697060#7692. Prof. Fumblemore and the Collatz ConjectureBackToSquare1AC ✓0ms3856kbC++201.6kb2024-11-01 10:04:242024-11-01 10:04:24

Judging History

你现在查看的是最新测评结果

  • [2024-11-01 10:04:24]
  • 评测
  • 测评结果:AC
  • 用时:0ms
  • 内存:3856kb
  • [2024-11-01 10:04:24]
  • 提交

answer

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, ll> pl;
typedef pair<ld,ld> pd;
typedef vector<ll> vl;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
 
#define G(x) ll x; cin >> x;
#define F(i, l, r) for (ll i = l; i < (r); ++i)
#define all(a) begin(a), end(a)
#define K first
#define V second
#define OK(i,j) i >= 0 && i < n && j >= 0 && j < m
 
#define NN 2000005
#define MM 5005
#define MOD 1000000007

void solve() {
 
    string s;
    cin >> s;
    ll n = s.length();
    bool ok = 1;
    for(ll i=0;i<n;i++) {
        if(s[i] != 'E' && s[i] != 'O') ok = 0;
    }

    if(s[n-1] != 'O') ok = 0;

    for(ll i=1;i<n;i++) {
        if(s[i] == 'O' && s[i-1] == 'O') ok = 0;
    }

    if(!ok) {
        cout << "INVALID\n";
        return;
    }

    ll ans = 1e18;
    ll num = 8;
    for(ll c=3;c<=63;c++) {
        ll k = num;
        ok = 1;
        for(ll i=n-1;i>=0;i--) {
            if(s[i] == 'O') {
                if((k-1)%3 != 0) ok = 0;
                else k = (k-1)/3;
            }
            else k = 2*k;
            if(k < 0) ok = 0;
        }
        if(ok) ans = min(ans,k);
        num *= 2;
    }

    if(ans > pow(2,47)) cout << "INVALID\n";
    else cout << ans << '\n';
    return;
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cout << fixed << setprecision(10);

    // G(t);
    // while(t--)
        solve();

    return 0;

}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3592kb

input:

EEOEO

output:

12

result:

ok single line: '12'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

EEOOEO

output:

INVALID

result:

ok single line: 'INVALID'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3504kb

input:

OEOEOEOEOEOEOEEEEEEOEEEOEEEOEEEOEOEEOEEEO

output:

383

result:

ok single line: '383'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

OEOEEEEEOEOEEEEOEEEEOEOEOEEOEEEO

output:

931

result:

ok single line: '931'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

OEEOEEOEEOEOEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO

output:

641

result:

ok single line: '641'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

OEOEEOEEOEEOEEOEEEEOEEEOEOEOEEEEEO

output:

683

result:

ok single line: '683'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

OEEOEEEOEOEEEEOEEEEOEOEOEEOEEEO

output:

465

result:

ok single line: '465'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

OEEOEEOEOEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO

output:

481

result:

ok single line: '481'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

OEEOEOEO

output:

201

result:

ok single line: '201'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

OEEEEOEEOEOEEEOEOEEOEEEO

output:

133

result:

ok single line: '133'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

OEOEOEOEEOEEEEEEEEEEOEOEOEEOEEEO

output:

943

result:

ok single line: '943'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

OEEEOEEO

output:

301

result:

ok single line: '301'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

OEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO

output:

407

result:

ok single line: '407'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

OEOEOEOEOEOEEOEEEEOEEEOEEEOEEEOEOEEOEEEO

output:

191

result:

ok single line: '191'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

OEEEOEO

output:

605

result:

ok single line: '605'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

OEOEOEOEEOEEEEOEEEOEEEOEEEOEOEEOEEEO

output:

431

result:

ok single line: '431'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

OEOEEEOEEEOEOEOEEEOEEEEOEOEEEOEOEEOEEEO

output:

563

result:

ok single line: '563'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3852kb

input:

OEEOEEEEEOEEOEEEO

output:

241

result:

ok single line: '241'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3556kb

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: 0ms
memory: 3648kb

input:

OEOEOEOEOEOEEEEEEOEEEOEEEOEEEOEOEEOEEEO

output:

575

result:

ok single line: '575'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

EEOEEOEOEEEEEOEOEOEEEEEO

output:

868

result:

ok single line: '868'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

OEOEOEO

output:

26512143

result:

ok single line: '26512143'

Test #24:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

OEOEOEEO

output:

13256071

result:

ok single line: '13256071'

Test #25:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

EEO

output:

20

result:

ok single line: '20'

Test #26:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

EOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEE

output:

INVALID

result:

ok single line: 'INVALID'

Test #27:

score: 0
Accepted
time: 0ms
memory: 3504kb

input:

EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEO

output:

43980465111040

result:

ok single line: '43980465111040'

Test #28:

score: 0
Accepted
time: 0ms
memory: 3496kb

input:

EEEEEEEEEEOEEEOEEEEOEOEEOEEEEEOEEEEEEEOEEOEEEEEEEO

output:

7321693729792

result:

ok single line: '7321693729792'

Test #29:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

EEEOEEEOEEOEEEEEOEEEEEEEOEEEEEEEEEEEEEEEEOEEEEEO

output:

1028529777000

result:

ok single line: '1028529777000'