Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <string>
- #include <map>
- using namespace std;
- struct kor
- {
- int x,y;
- };
- int main()
- {
- string s=".abcd",s1=".1234";
- int a[5][5];
- map<int,kor> ch,tr;
- for (int i=1; i<=16; i++)
- {
- tr[i].x=(i-1)/4 +1;
- tr[i].y=(i%4==0 ? 4:(i%4));
- }
- for (int i=1; i<5; i++)
- {
- for (int j=1; j<5; j++)
- {
- cin>>a[i][j];
- ch[a[i][j]].x=i;
- ch[a[i][j]].y=j;
- }
- }
- vector<string> ans;
- for (int i=1; i<=16; i++)
- {
- if (ch[i].x!= tr[i].x || ch[i].y!=tr[i].y || (ch[i].x!= tr[i].x && ch[i].y!=tr[i].y ))
- {
- int x;
- int y;
- string l="";
- l+=s[tr[i].x];
- l+=s1[tr[i].y];
- l+='-';
- l+=s[ch[i].x];
- l+=s1[ch[i].y];
- ans.push_back(l);
- x=ch[i].x;
- y=ch[i].y;
- int n;
- for (int j=1; j<=16; j++)
- {
- if (ch[j].x==tr[i].x &&ch[j].y==tr[i].y)
- {
- n=j;
- break;
- }
- }
- ch[n].x=x;
- ch[n].y=y;
- ch[i].x=tr[i].x;
- ch[i].y=tr[i].y;
- }
- }
- cout<<ans.size()<<endl;
- for (int i=0; i<ans.size(); i++)
- {
- cout<<ans[i]<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment