QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#331965 | #7692. Prof. Fumblemore and the Collatz Conjecture | cry# | AC ✓ | 127ms | 3872kb | C++14 | 4.3kb | 2024-02-19 02:06:47 | 2024-02-19 02:06:48 |
Judging History
answer
// #include <bits/stdc++.h>
// using namespace std;
// using ll = long long;
// map<char, string> mp;
// map<char, string> revmp;
// void envy(){
// mp['A'] = "01";
// mp['B'] = "1000";
// mp['C'] = "1010";
// mp['D'] = "100";
// mp['E'] = "0";
// mp['F'] = "0010";
// mp['G'] = "110";
// mp['H'] = "0000";
// mp['I'] = "OO";
// mp['J'] = "0111";
// mp['K'] = "101";
// mp['L'] = "0100";
// mp['M'] = "11";
// mp['N'] = "10";
// mp['O'] = "111";
// mp['P'] = "0110";
// mp['Q'] = "1101";
// mp['R'] = "010";
// mp['S'] = "000";
// mp['T'] = "1";
// mp['U'] = "001";
// mp['V'] = "0001";
// mp['W'] = "011";
// mp['X'] = "1001";
// mp['Y'] = "1011";
// mp['Z'] = "1100";
// mp['0'] = "11111";
// mp['1'] = "01111";
// mp['2'] = "00111";
// mp['3'] = "00011";
// mp['4'] = "00001";
// mp['5'] = "00000";
// mp['6'] = "10000";
// mp['7'] = "11000";
// mp['8'] = "11100";
// mp['9'] = "11110";
// for(char c = 'A'; c <= 'Z'; c++){
// revmp[c] = mp[c];
// reverse(revmp[c].begin(), revmp[c].end());
// }
// for(char c = '0'; c <= '9'; c++){
// revmp[c] = mp[c];
// reverse(revmp[c].begin(), revmp[c].end());
// }
// }
// struct item{
// string morse;
// vector<char> v;
// };
// int main() {
// ios_base::sync_with_stdio(false);
// cin.tie(0);
// envy();
// string s; cin >> s;
// string ns;
// for(int i = 0; i < s.size(); i++){
// if(s[i] >= 'A' && s[i] <= 'Z'){
// ns.push_back(s[i]);
// }
// if(s[i] >= '0' && s[i] <= '9'){
// ns.push_back(s[i]);
// }
// }
// s = ns;
// int n = s.size();
// string morsed;
// for(char c: s){
// morsed += mp[c];
// }
// reverse(morsed.begin(), morsed.end());
// queue<item> q;
// q.push({"", {}});
// while(q.empty()){
// }
// // int n; int m;
// // cin >> n >> m;
// // vector<array<int, 2>> p(n);
// // for(int i = 0; i < n; i++) {
// // cin >> p[i][0] >> p[i][1];
// // }
// // vector<vector<array<int, 3>>> adj(n, vector<array<int, 2>>(4, {-1, -1}));
// // vector<int> inter(m);
// // for(int i = 0; i < m; i++) {
// // int ii; int ji; int ki;
// // cin >> ii >> ji >> ki;
// // ii--; ji--;
// // inter[i] = ki;
// // if(p[ii][0] < p[ji][0]) {
// // adj[ii][1] = {ji, i};
// // } else if(p[ii][0] > p[ji][0]) {
// // } else if(p[ii][1] < p[ji][1]) {
// // } else {
// // }
// // }
// }
// // 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 < 1000; 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;
// // }
// // }
#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){
if(__builtin_popcount(start * 3 + 1) != 1) {
continue;
}
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(res % 2 == 0){
ok = false;
break;
}
}
if(__builtin_popcountll(res) == 1){
ok = false;
break;
}
}
if(ok){
cout << res << "\n";
break;
}
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3836kb
input:
EEOEO
output:
12
result:
ok single line: '12'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
EEOOEO
output:
INVALID
result:
ok single line: 'INVALID'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
OEOEOEOEOEOEOEEEEEEOEEEOEEEOEEEOEOEEOEEEO
output:
383
result:
ok single line: '383'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
OEOEEEEEOEOEEEEOEEEEOEOEOEEOEEEO
output:
931
result:
ok single line: '931'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
OEEOEEOEEOEOEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO
output:
641
result:
ok single line: '641'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
OEOEEOEEOEEOEEOEEEEOEEEOEOEOEEEEEO
output:
683
result:
ok single line: '683'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
OEEOEEEOEOEEEEOEEEEOEOEOEEOEEEO
output:
465
result:
ok single line: '465'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
OEEOEEOEOEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO
output:
481
result:
ok single line: '481'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3576kb
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: 3640kb
input:
OEEEOEEO
output:
301
result:
ok single line: '301'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
OEOEOEEEEEEOEOEEOEEOEEEEOEOEOEEOEEEO
output:
407
result:
ok single line: '407'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
OEOEOEOEOEOEEOEEEEOEEEOEEEOEEEOEOEEOEEEO
output:
191
result:
ok single line: '191'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
OEEEOEO
output:
605
result:
ok single line: '605'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
OEOEOEOEEOEEEEOEEEOEEEOEEEOEOEEOEEEO
output:
431
result:
ok single line: '431'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
OEOEEEOEEEOEOEOEEEOEEEEOEOEEEOEOEEOEEEO
output:
563
result:
ok single line: '563'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
OEEOEEEEEOEEOEEEO
output:
241
result:
ok single line: '241'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
OEEEOEEEEOEOEEEOEOEEOEEEO
output:
269
result:
ok single line: '269'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
EEOEOEOEEOEEEEOEOEEOEEOEEEEOEOEOEEOEEEO
output:
540
result:
ok single line: '540'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
OEOEOEOEOEOEEEEEEOEEEOEEEOEEEOEOEEOEEEO
output:
575
result:
ok single line: '575'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
EEOEEOEOEEEEEOEOEOEEEEEO
output:
868
result:
ok single line: '868'
Test #23:
score: 0
Accepted
time: 127ms
memory: 3608kb
input:
OEOEOEO
output:
26512143
result:
ok single line: '26512143'
Test #24:
score: 0
Accepted
time: 32ms
memory: 3528kb
input:
OEOEOEEO
output:
13256071
result:
ok single line: '13256071'
Test #25:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
EEO
output:
20
result:
ok single line: '20'
Test #26:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
EOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEOEE
output:
INVALID
result:
ok single line: 'INVALID'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEO
output:
43980465111040
result:
ok single line: '43980465111040'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
EEEEEEEEEEOEEEOEEEEOEOEEOEEEEEOEEEEEEEOEEOEEEEEEEO
output:
7321693729792
result:
ok single line: '7321693729792'
Test #29:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
EEEOEEEOEEOEEEEEOEEEEEEEOEEEEEEEEEEEEEEEEOEEEEEO
output:
1028529777000
result:
ok single line: '1028529777000'