Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define nl "\n"
- void files(){
- ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- void solve(){
- string s,t;
- int k;
- cin>>s>>k>>t;
- int n = s.size();
- if(n%k){
- cout<<"0";
- return;
- }
- if((int)t.size() != n){
- cout<<"0";
- return;
- }
- map<string,int>mp;
- int d = n/k;
- for(int i=0; i<n; i+=d){
- string temp = s.substr(i,d);
- mp[temp]++;
- }
- for(int i=0;i<n;i+=d){
- string temp = t.substr(i,d);
- if(mp[temp]){
- mp[temp]--;
- }else{
- cout<<"0";
- return;
- }
- }
- for(auto&[x,y]:mp){
- if(y){
- cout<<"0";
- return;
- }
- }
- cout<<"1";
- }
- int main(){
- files();
- int t = 1;
- // cin>>t;
- while(t--) solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement