Submission #789460

#TimeUsernameProblemLanguageResultExecution timeMemory
789460Trisanu_Das Martian DNA (BOI18_dna)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int x; int main(){ int n, k, cnt; int a[n + 1], b[n + 1], ccnt[n + 1]; memset(cnt, 0, sizeof(ccnt)); for(int i = 1; i < n + 1; i++) cin >> a[i]; for(int i = 1; i < cnt + 1; i++){ cin >> x; cin >> b[x]; } int l = 1, r = 0, ans = INT_MAX; while(r < n + 1){ if(cnt){ r++; ccnt[a[r]]++; if(ccnt[a[r]] == b[a[r]]) cnt--; }else{ ans = min(ans, r - l + 1); if(ccnt[a[l]] == b[a[l]]) cnt++; ccnt[a[l]]--; l++; } } if(ans == INT_MAX) cout << "impossible\n"; else cout << ans << '\n'; }

Compilation message (stderr)

dna.cpp: In function 'int main()':
dna.cpp:8:47: error: invalid conversion from 'int' to 'void*' [-fpermissive]
    8 |   int a[n + 1], b[n + 1], ccnt[n + 1]; memset(cnt, 0, sizeof(ccnt));
      |                                               ^~~
      |                                               |
      |                                               int
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from dna.cpp:1:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:59:1: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
   59 | __NTH (memset (void *__dest, int __ch, size_t __len))
      | ^~~~~
dna.cpp:7:10: warning: unused variable 'k' [-Wunused-variable]
    7 |   int n, k, cnt;
      |          ^