結果
| 問題 |
No.2868 Another String of yuusaan
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-30 23:02:21 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,706 bytes |
| コンパイル時間 | 2,169 ms |
| コンパイル使用メモリ | 197,660 KB |
| 最終ジャッジ日時 | 2025-02-24 03:20:40 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
long long N,K; cin >> N >> K;
if(N >= K){cout << "y" << endl; return 0;}
vector<long long> len(27);
long long l = 1,add = 6;
for(int i=0; i<27; i++){
len.at(i) = l;
l += add; add *= 4;
}
string s = "yuusaan";
char answer;
auto dfs = [&](auto dfs,int level,long long left) -> void {
level--;
if(level == 0){
answer = s.at(left-1);
cout << s.at(left-1) << endl;
return;
}
if(left == 1){answer = 'y'; cout << "y" << endl; return;}
left--;
if(left <= len.at(level)){dfs(dfs,level,left); return;}
left -= len.at(level);
if(left <= len.at(level)){dfs(dfs,level,left); return;}
left -= len.at(level);
if(left == 1){answer = 's'; cout << "s" << endl; return;}
left--;
if(left <= len.at(level)){dfs(dfs,level,left); return;}
left -= len.at(level);
if(left <= len.at(level)){dfs(dfs,level,left); return;}
left -= len.at(level);
if(left == 1){answer = 'n'; cout << "n" << endl; return;}
assert(false);
};
long long dec = max(0LL,N-27);
dfs(dfs,min(N,27LL),K-dec);
return 0;
for(int i=2; i<=N; i++){
string t = "";
for(auto &c : s){
if(c == 'u' || c == 'a') t += "yuusaan";
else t += c;
}
swap(s,t);
}
if(s.at(K-1) != answer){
cout << N << " " << K << endl;
cout << s.at(K-1) << " " << answer << endl;
assert(false);
}
//cout << s.at(K-1) << endl;
}