codeforces727E Games on a CD
Posted 恶devil魔
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了codeforces727E Games on a CD相关的知识,希望对你有一定的参考价值。
/* *********************************************** Author :devil ************************************************ */ #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <stack> #include <map> #include <unordered_map> #include <string> #include <time.h> #include <cmath> #include <stdlib.h> #define LL long long #define rep(i,a,b) for(int i=a;i<=b;i++) #define dep(i,a,b) for(int i=a;i>=b;i--) #define ou(a) printf("%d\n",a) #define pb push_back #define pii pair<int,int> #define mkp make_pair #define IN freopen("in.txt","r",stdin); #define OUT freopen("out.txt","w",stdout); using namespace std; const int inf=0x3f3f3f3f; const int mod=1e9+7; const int N=1e5+10; unordered_map<string,int>mp; int n,l,m; string s,u; int main() { cin>>n>>l>>s>>m; s+=s; for(int i=1;i<=m;i++) { cin>>u; mp[u]=i; } int L=n*l; bool ok; vector<int>ans(n,0); for(int ind=L-l;ind<L;ind++) { ok=1; vector<bool>mk(m+1,0); for(int i=0;i<n&&ok;i++) { auto it=mp.find(s.substr(ind+i*l,l)); if(it==mp.end()||mk[it->second]) { ok=0; break; } mk[it->second]=1; ans[i]=it->second; } if(ok) break; } if(!ok) printf("NO\n"); else { printf("YES\n"); for(auto j:ans) printf("%d ",j); } return 0; }
以上是关于codeforces727E Games on a CD的主要内容,如果未能解决你的问题,请参考以下文章
CodeForces727E/CF727EGames on a CD (字符串哈希)
Codeforces 455 B. A Lot of Games
Codeforces 455B A Lot of Games 字典树上博弈
CodeForces 456D&455B--A Lot of Games(Trie+博弈)