Submission #1272715

#TimeUsernameProblemLanguageResultExecution timeMemory
1272715zNatsumiVještica (COCI16_vjestica)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int n, cnt[20][26], f[(1<<16) + 5], dup[(1<<16) + 5]; int32_t main(){ cin.tie(0)->sync_with_stdio(0); // #define task "test" // if(fopen(task ".inp", "r")){ // freopen(task ".inp", "r", stdin); // freopen(task ".out", "w", stdout); // } cin >> n; for(int i = 0; i < n; i++){ string s; cin >> s; for(auto x : s) cnt[i][x - 'a'] += 1; f[1 << i] = s.size(); } for(int msk = 1; msk < (1 << n); msk++){ for(int x = 0; x < 26; x++){ int tmp = 1'000'000'000; for(int i = 0; i < n; i++) if(msk >> i & 1) tmp = min(tmp, cnt[i][x]); dup[msk] += tmp; } } for(int msk = 1; msk < (1 << n); msk++){ if(__builtin_popcount(msk) == 1) continue; f[msk] = 1'000'000'000; for(int sub = msk; sub > 0; sub = (sub - 1) & msk) if(sub != msk) f[msk] = min(f[msk], f[sub] + f[msk ^ sub] - dup[msk]); } cout << f[(1 << n) - 1] + 1 << "\n"; return 0; }

Compilation message (stderr)

vjestica.cpp:5:52: error: 'int dup [65541]' redeclared as different kind of entity
    5 | int n, cnt[20][26], f[(1<<16) + 5], dup[(1<<16) + 5];
      |                                                    ^
In file included from /usr/include/c++/13/bits/atomic_wait.h:45,
                 from /usr/include/c++/13/bits/atomic_base.h:42,
                 from /usr/include/c++/13/bits/shared_ptr_atomic.h:33,
                 from /usr/include/c++/13/memory:81,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:56,
                 from vjestica.cpp:1:
/usr/include/unistd.h:552:12: note: previous declaration 'int dup(int)'
  552 | extern int dup (int __fd) __THROW __wur;
      |            ^~~
vjestica.cpp: In function 'int32_t main()':
vjestica.cpp:25:14: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   25 |       dup[msk] += tmp;
      |              ^
vjestica.cpp:25:16: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   25 |       dup[msk] += tmp;
      |       ~~~~~~~~~^~~~~~
vjestica.cpp:25:16: error: assignment of read-only location '*(dup + ((sizetype)msk))'
vjestica.cpp:33:74: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   33 |       if(sub != msk) f[msk] = min(f[msk], f[sub] + f[msk ^ sub] - dup[msk]);
      |                                                                          ^
vjestica.cpp:33:65: error: invalid operands of types 'int' and 'int(int) noexcept' to binary 'operator-'
   33 |       if(sub != msk) f[msk] = min(f[msk], f[sub] + f[msk ^ sub] - dup[msk]);
      |                                           ~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~
      |                                                  |                       |
      |                                                  int                     int(int) noexcept