Submission #913825

#TimeUsernameProblemLanguageResultExecution timeMemory
913825cotBeautiful row (IZhO12_beauty)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <algorithm> #include <map> #include <array> #define int long long #define f first #define s second #define pb push_back #define int long long using namespace std; const int N = 21; int fix[N][N],lst,ans,lst1,a[N],n,dp[(1<<N)][N]; int ones(int x) { int cnt = 0; while (x) { cnt += ((x%3)==1); x/=3; } return cnt; } signed main() { cin>>n; for (int i = 0; i < n; i++) { cin>>a[i]; } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (__builtin_popcount(a[i]) == __builtin_popcount(a[j])) { fix[i][j] = fix[j][i] = 1; continue; } if (ones(a[i]) == ones(a[j])) { fix[i][j] = fix[j][i] = 1; continue; } } } for (int i = 1; i < (1<<n); i++) { vector <int> v; for (int j = 0; j < n; j++) { if ((1<<j)&i) v.pb(j); } if (__builtin_popcount(i) == 1){ dp[i][v[0]] = 1; continue; } for (int j = 0; j < v.size(); j++) { lst = v[j]; for (int j1 = 0; j1 < v.size(); j1++) { lst1 = v[j1]; if (j == j1) continue; if (fix[lst][lst1]) { dp[i][lst] += dp[i ^ (1<<lst)][lst1]; } } if (i == (1<<n) - 1) ans += dp[i][lst];//, ans %= mod; } } cout<<ans<<endl; }

Compilation message (stderr)

beauty.cpp: In function 'int main()':
beauty.cpp:39:9: error: 'vector' was not declared in this scope
   39 |         vector <int> v;
      |         ^~~~~~
beauty.cpp:4:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    3 | #include <map>
  +++ |+#include <vector>
    4 | #include <array>
beauty.cpp:9:13: error: expected primary-expression before 'long'
    9 | #define int long long
      |             ^~~~
beauty.cpp:39:17: note: in expansion of macro 'int'
   39 |         vector <int> v;
      |                 ^~~
beauty.cpp:41:27: error: 'v' was not declared in this scope
   41 |             if ((1<<j)&i) v.pb(j);
      |                           ^
beauty.cpp:43:48: error: 'v' was not declared in this scope
   43 |         if (__builtin_popcount(i) == 1){ dp[i][v[0]] = 1; continue; }
      |                                                ^
beauty.cpp:44:29: error: 'v' was not declared in this scope
   44 |         for (int j = 0; j < v.size(); j++) { lst = v[j];
      |                             ^