Submission #44022600


Source Code Expand

#include<bits/stdc++.h>
#include<atcoder/string>
using namespace std;
#define rep(i,l,r)for(int i=(l);i<(r);i++)

int main(){
	int n;
	cin >> n;
	vector<string>S(n);
	rep(i,0,n)cin >> S[i];
	
	unordered_map<string,vector<int>>memo;
	rep(i,0,n){
		auto ret=atcoder::z_algorithm(S[i]);
		int len=S[i].size();
		int ans=len;
		rep(j,1,len)if(len%j==0&&ret[j]==len-j){
			ans=j;
			break;
		}
		memo[S[i].substr(0,ans)].push_back(i);
	}
	
	vector<int>ans(n);
	for(auto[k,v]:memo){
		unordered_map<int,int>pre;
		unordered_set<int>used;
		used.insert(0);
		
		for(auto i:v){
			int d=S[i].size()/k.size();
			int crr=pre[d];
			while(used.find(crr)!=used.end())crr+=d;
			pre[d]=crr;
			used.insert(crr);
			ans[i]=crr/d;
		}
	}
	
	rep(i,0,n){
		if(i)cout << ' ';
		cout << ans[i];
	}
	cout << endl;
}

Submission Info

Submission Time
Task Ex - snukesnuke
User kyopro_friends
Language C++ (GCC 9.2.1)
Score 600
Code Size 842 Byte
Status AC
Exec Time 103 ms
Memory 19996 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 31
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt AC 73 ms 8936 KiB
random_02.txt AC 74 ms 8996 KiB
random_03.txt AC 24 ms 5848 KiB
random_04.txt AC 28 ms 5740 KiB
random_05.txt AC 11 ms 4020 KiB
random_06.txt AC 13 ms 4068 KiB
random_07.txt AC 15 ms 5208 KiB
random_08.txt AC 93 ms 19996 KiB
random_09.txt AC 91 ms 19928 KiB
random_10.txt AC 58 ms 11652 KiB
random_11.txt AC 59 ms 11664 KiB
random_12.txt AC 19 ms 4448 KiB
random_13.txt AC 25 ms 4628 KiB
random_14.txt AC 11 ms 3900 KiB
random_15.txt AC 13 ms 3884 KiB
random_16.txt AC 14 ms 5080 KiB
random_17.txt AC 11 ms 5152 KiB
random_18.txt AC 17 ms 4080 KiB
random_19.txt AC 17 ms 3956 KiB
random_20.txt AC 14 ms 3860 KiB
random_21.txt AC 16 ms 4024 KiB
random_22.txt AC 11 ms 3800 KiB
random_23.txt AC 37 ms 7520 KiB
random_24.txt AC 38 ms 7452 KiB
random_25.txt AC 14 ms 4168 KiB
random_26.txt AC 85 ms 16644 KiB
random_27.txt AC 103 ms 19176 KiB
random_28.txt AC 5 ms 3520 KiB
sample_01.txt AC 3 ms 3572 KiB
sample_02.txt AC 2 ms 3520 KiB
sample_03.txt AC 2 ms 3552 KiB