結果

問題 No.2198 Concon Substrings (COuNt-CONstruct Version)
ユーザー 沙耶花
提出日時 2023-01-20 21:41:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 1,031 bytes
コンパイル時間 3,590 ms
コンパイル使用メモリ 251,716 KB
最終ジャッジ日時 2025-02-10 04:38:44
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 104
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001

long long get(string s){
	long long a = 0,b = 0,c = 0;
	rep(i,s.size()){
		if(s[i]=='c')a++;
		else if(s[i]=='o')b += a;
		else c += b;
	}
	return c;
}

int main(){
	
	string s = "co";
	rep(i,10000)s += 'c';
	rep(i,10000)s += 'o';
	
	long long M;
	cin>>M;
	
	vector<long long> pos(s.size()+1,0);
	long long x = 0,y = 0;
	rep(i,s.size()){
		if(s[i]=='c')x++;
		else{
			y += x;
		}
		pos[i+1] = y;
	}
//	cout<<pos[2]<<endl;
	//cout<<x<<','<<y<<endl;
	vector<int> cnt(s.size()+1,0);
	for(int i=s.size();i>=0;i--){
		//cout<<M<<endl;
		while(M!=0 && M>=pos[i]){
			cnt[i]++;
			M -= pos[i];
		}
	}
	//cout<<M<<endl;
	string ans = "";
	rep(i,s.size()){
		ans += s[i];
		rep(j,cnt[i+1])ans += 'n';
	}
	
	cout<<ans<<endl;
	//cout<<get(ans)<<endl;
	//cout<<ans.size()<<endl;
	return 0;
}
0