Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- char mem[1005];
- int mp[25][1005];
- int main()
- {
- int n;
- cin >> n;
- cin >> mem;
- // cout << mem;
- int loop,cntx=n-1,cnty=0,cnt=1;
- loop=strlen(mem)/(4*n-4);
- for(int i=0;i<=loop;i++)
- {
- for(int j=0;j<n;j++)
- {
- // cout << "hey" << endl;
- mp[cntx--][cnty]=1;
- cnt++;
- if(cnt==strlen(mem)+1) break;
- }
- if(cnt==strlen(mem)+1) break;
- cntx++;
- cnty++;
- for(int j=0;j<n-1;j++)
- {
- mp[cntx][cnty++]=1;
- cnt++;
- if(cnt==strlen(mem)+1) break;
- // cout << "2hey" << endl;
- }
- if(cnt==strlen(mem)+1) break;
- cnty--;
- cntx++;
- for(int j=0;j<n-1;j++)
- {
- mp[cntx++][cnty]=1;
- cnt++;
- if(cnt==strlen(mem)+1) break;
- }
- if(cnt==strlen(mem)+1) break;
- cntx--;
- cnty++;
- for(int j=0;j<n-2;j++)
- {
- mp[cntx][cnty++]=1;
- cnt++;
- if(cnt==strlen(mem)+1) break;
- }
- if(cnt==strlen(mem)+1) break;
- }
- cntx=0;
- // for(int i=0;i<5;i++)
- // {
- // for(int j=0;j<40;j++)
- // {
- // if(mp[i][j]) cout << mp[i][j];
- // else cout << ".";
- // }
- // cout << endl;
- // }
- for(int i=0;i<n;i++)
- {
- for(int j=0;j<1005;j++)
- {
- if(mp[i][j]) mp[i][j]=mem[cntx++];
- if(!mem[cntx])break;
- }
- if(!mem[cntx])break;
- }
- // for(int i=0;i<n;i++)
- // {
- // for(int j=0;j<1005;j++)
- // {
- // if(mp[i][j]) printf("%c",mp[i][j]);
- // else cout << ".";
- // }
- // cout << endl;
- // }
- cntx=n-1,cnty=0;
- for(int i=0;i<=loop;i++)
- {
- for(int j=0;j<n;j++)
- {
- printf("%c",mp[cntx--][cnty]);
- }
- cntx++;
- cnty++;
- for(int j=0;j<n-1;j++)
- {
- printf("%c",mp[cntx][cnty++]);
- }
- cnty--;
- cntx++;
- for(int j=0;j<n-1;j++)
- {
- printf("%c",mp[cntx++][cnty]);
- }
- cntx--;
- cnty++;
- for(int j=0;j<n-2;j++)
- {
- printf("%c",mp[cntx][cnty++]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement