結果

問題 No.3317 ワロングアンサーロングアンサーンスワロンガー
コンテスト
ユーザー Carpenters-Cat
提出日時 2025-10-31 23:30:22
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 817 bytes
コンパイル時間 2,016 ms
コンパイル使用メモリ 200,664 KB
実行使用メモリ 11,048 KB
最終ジャッジ日時 2025-10-31 23:30:40
合計ジャッジ時間 16,193 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 21 WA * 29 RE * 5 TLE * 1 -- * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
std::vector<ll> Ls;
ll len(char c, int t) {
	if (c == 'a' || c == 'w') {
		return Ls[t];
	} else {
		return 1;
	}
}
vector<string> S(26);
char calc(const string& s, int t, ll x) {
	if (x == 0) {
		return s[0];
	}
	for (auto& c : s) {
		if (x < len(c, t)) {
			return calc(S[c - 'a'], t-1, x);
		}
		x -= len(c, t);
	}
	assert(false);
}
int main () {
	int N, Q;
	cin >> N >> Q;
	{
		ll fl = 1;
		int id = 0;
		while (fl <= (ll)1e18) {
			Ls.push_back(fl);
			fl += (1ll << id) * 5;
			id ++;
		}
	}
	for (int i = 0; i < 26; i ++) {
		S[i] = string(1, 'a' + (char)i);
	}
	S[0] = "answer"; S[22] = "warong";
	string s;
	cin >> s;
	while (Q--) {
		ll t, x;
		cin >> t >> x;
		t = min(t, (ll)Ls.size() - 1);
		cout << calc(s, t, --x);
	}
	cout << endl;
}
0