QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#876190 | #7692. Prof. Fumblemore and the Collatz Conjecture | LaVuna47# | WA | 0ms | 3712kb | C++20 | 2.1kb | 2025-01-30 18:11:32 | 2025-01-30 18:11:33 |
Judging History
answer
//A tree without skin will surely die.
//A man without face is invincible.
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#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
ll next(ll x)
{
if(x%2==0)return x/2;
return x*3+1;
}
__int128 prev(__int128 x)
{
if((x-1) % 3 == 0)
return (x-1)/3;
else return x*2;
}
int solve()
{
string s;
if(!(cin>>s))return 1;
int n=sz(s);
bool ok=true;
if(s[n-1] == 'E')ok=false;
FOR(i,0,n) if(!(s[i]=='E' || s[i] == 'O'))ok=false;
FOR(i,0,n-1)
{
if(s[i]=='O' && s[i+1]=='O')ok=false;
}
if(ok)
{
for(__int128 i = 1; i <= 120; ++i)
{
string t;
__int128 num=((__int128)1 << i);
while(sz(t) < n)
{
num=prev(num);
if(num % 2==0)
t += 'E';
else
t += 'O';
}
reverse(all(t));
if(t==s)
{
cout<<(ll)num<<'\n';
return 0;
}
}
cout<<"INVALID\n";
}
else
{
cout<<"INVALID\n";
}
return 0;
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int TET = 1e9;
//cin >> TET;
for (int i = 1; i <= TET; i++)
{
if (solve())
{
break;
}
#ifdef ONPC
cout << "__________________________" << endl;
#endif
}
#ifdef ONPC
cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3712kb
input:
EEOEO
output:
12
result:
ok single line: '12'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
EEOOEO
output:
INVALID
result:
ok single line: 'INVALID'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3712kb
input:
OEOEOEOEOEOEOEEEEEEOEEEOEEEOEEEOEOEEOEEEO
output:
INVALID
result:
wrong answer 1st lines differ - expected: '383', found: 'INVALID'