Submission #493497

# Submission time Handle Problem Language Result Execution time Memory
493497 2021-12-11T18:19:51 Z Homichki Beautiful row (IZhO12_beauty) C++14
0 / 100
1738 ms 324 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
ll st3(ll x)
{
    ll kol=0;
    while(x>0)
    {
        if(x%3==1)
        {
            kol++;
        }
        x/=3;
    }
    return kol;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
    vector<ll> a,b;
    string s;
    char s1;
    cin>>n;
    if(n>10)
    {
        return 0;
    }
    for(i=0;i<n;i++)
    {
        cin>>x;
        a.push_back(x);
        b.push_back(i);
    }
    sort(b.begin(),b.end());
    kol=0;
    do
    {
        kry=0;
        for(i=1;i<n;i++)
        {
            y=__builtin_popcount(a[b[i-1]]);
            x=__builtin_popcount(a[b[i]]);
            l=st3(a[b[i-1]]);
            r=st3(a[b[i]]);
            if((y!=x) && (l!=r))
            {
                kry++;
                break;
            }
        }
        if(kry==0)
        {
            kol++;
        }
    }while(next_permutation(b.begin(),b.end()));
    cout<<kol;
    return 0;
}

Compilation message

beauty.cpp: In function 'int main()':
beauty.cpp:24:8: warning: unused variable 'k' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |        ^
beauty.cpp:24:10: warning: unused variable 'm' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |          ^
beauty.cpp:24:12: warning: unused variable 'x1' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |            ^~
beauty.cpp:24:15: warning: unused variable 'y1' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |               ^~
beauty.cpp:24:18: warning: unused variable 'p' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                  ^
beauty.cpp:24:20: warning: unused variable 'qqq' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                    ^~~
beauty.cpp:24:26: warning: unused variable 'j' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                          ^
beauty.cpp:24:28: warning: unused variable 'z' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                            ^
beauty.cpp:24:42: warning: unused variable 'w' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                          ^
beauty.cpp:24:44: warning: unused variable 'sum' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                            ^~~
beauty.cpp:24:48: warning: unused variable 't' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                                ^
beauty.cpp:24:52: warning: unused variable 'h' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                                    ^
beauty.cpp:24:54: warning: unused variable 'mew' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                                      ^~~
beauty.cpp:24:58: warning: unused variable 'ma' [-Wunused-variable]
   24 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                                          ^~
beauty.cpp:27:10: warning: unused variable 's1' [-Wunused-variable]
   27 |     char s1;
      |          ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 202 ms 292 KB Output is correct
7 Correct 161 ms 300 KB Output is correct
8 Correct 627 ms 204 KB Output is correct
9 Correct 184 ms 324 KB Output is correct
10 Correct 1738 ms 284 KB Output is correct
11 Incorrect 0 ms 204 KB Output isn't correct
12 Halted 0 ms 0 KB -