Submission #856702

#TimeUsernameProblemLanguageResultExecution timeMemory
856702ntkphongLottery (CEOI18_lot)C++14
45 / 100
18 ms31780 KiB
#include <bits/stdc++.h> using namespace std; const int mxN = 2000 + 10; int n, l, q; int a[mxN]; int dp[mxN][mxN]; int prefix[mxN]; int answer[mxN][mxN]; int main() { #define taskname "" if(fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } cin.tie(0)->sync_with_stdio(0); cin >> n >> l; if(n > 2000) return 0; for(int i = 1; i <= n; i ++) cin >> a[i]; for(int i = 1; i <= n; i ++) { for(int j = 1; j <= n; j ++) { dp[i][j] = dp[i - 1][j - 1] + (a[i] != a[j]); } } for(int i = l; i <= n; i ++) { for(int j = l; j <= n; j ++) { int x = dp[i][j] - dp[i - l][j - l]; prefix[x] ++ ; } answer[i - l + 1][0] = prefix[0]; for(int j = 1; j <= n; j ++) { prefix[j] += prefix[j - 1]; answer[i - l + 1][j] = prefix[j]; } for(int j = 0; j <= n; j ++) prefix[j] = 0; } cin >> q; while(q --) { int k; cin >> k; for(int i = 1; i <= n - l + 1; i ++) { cout << answer[i][k] - 1 << " "; } cout << "\n"; } return 0; }

Compilation message (stderr)

lot.cpp: In function 'int main()':
lot.cpp:16:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
lot.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...