Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <queue>
- #include <algorithm>
- #include <string>
- #include <stack>
- #include <set>
- #include <map>
- #define pii pair <int,int>
- #define vec vector
- using namespace std;
- using ll = long long;
- using ld = long double;
- using db = double;
- void cv(vector <int> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvl(vector <ll> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvv(vector <vector <int> > &v){
- for (auto x: v) cv(x);
- cout<<"\n\n";
- }
- void cvb(vector <bool> v){
- for (bool x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvs(vector <string> v){
- for (auto a: v){
- cout<<a<<"\n";
- }
- }
- vector <vector <int> > f(int N){
- vector <vector <int> > mas(4, vector <int>(4,0));
- int k = 1;
- while (N > 0){
- cout<<"N = "<<N<<"\n";
- cout<<"N%16 = "<<N%16<<"\n";
- cout<<"N%16%4 = "<<N%16%4<<" N%16/4 = "<<N%16/4<<"\n";
- cout<<"k = "<<k<<"\n";
- mas[N%16%4][N%16/4]=k;
- //cvv(mas);
- k++;
- N/=16;
- }
- return mas;
- }
- vector <int> to(int x,int bs){
- vector <int> r={};
- while (x>0){
- r.push_back(x%bs);
- x/=bs;
- }
- while (r.size()<4){
- r.push_back(0);
- }
- reverse(r.begin(), r.end());
- return r;
- }
- vector<int> a= {7, 1, 13, 15},b= {5, 6, 11, 10},c= {14, 2, 16, 9},d= {8, 4, 12, 3};
- vector <vector <int> > goal = {a,b,c,d};
- int main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- //cvv(goal);
- vector <pii> v = {{2,2}, {0,3}, {2,0}, {0,2}, {3,2}, {1,2}, {1,3}, {2,3}, {3,0}, {0,0}, {1,1}, {1,0}, {3,1},{3,3}, {2,1}, {0,1} } ;
- reverse(v.begin(), v.end());
- vector <int> res={};
- for (int i =0;i<16;++i){
- int nm = v[i].first + 4 * v[i].second;
- auto p = to(nm, 2);
- for (int j: p){
- res.push_back(j);
- }
- }
- cv(res);
- reverse(res.begin(), res.end());
- int cnt=0;
- for (int i = 0; i < res.size();++i){
- if (i%3==0){
- cnt+=res[i];
- }
- }
- cout<<cnt;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement