Submission #260000

#TimeUsernameProblemLanguageResultExecution timeMemory
260000ly20Lottery (CEOI18_lot)C++17
0 / 100
101 ms65540 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 11234; int eq[MAXN][MAXN], resp[MAXN][MAXN]; int v[MAXN]; int main() { int n, l; int id = n - l + 1; scanf("%d %d", &n, &l); for(int i = 0; i < n; i++) { scanf("%d", &v[i]); for(int j = 0; j < i; j++) { if(v[i] != v[j]) continue; int ini1 = i - l + 1, fim1 = i, ini2 = j - l + 1, fim2 = j; int mn = min(ini1, ini2); if(mn < 0) { ini1 -= mn; ini2 -= mn; } int mx = max(fim1, fim2); eq[ini1][ini2]++; if(fim1 + 1 < id && fim2 + 1 < id) eq[fim1 + 1][fim2 + 1]--; //printf("%d %d %d %d\n", ini1, ini2, fim1, fim2); } } for(int i = 1; i < id; i++) { for(int j = 1; j < id; j++) { eq[i][j] += eq[i - 1][j - 1]; } } for(int i = 0; i < id; i++) { for(int j = 0; j < id; j++) { resp[i][l - eq[i][j]]++; } } for(int i = 0; i < id; i++) { for(int j = 1; j < l; j++) { resp[i][j] += resp[i][j - 1]; } } int q; scanf("%d", &q); for(int i = 0; i < q; i++) { int r; scanf("%d", &r); for(int j = 0; j < id; j++) { printf("%d ", resp[j][r]); } printf("\n"); } return 0; }

Compilation message (stderr)

lot.cpp: In function 'int main()':
lot.cpp:19:8: warning: unused variable 'mx' [-Wunused-variable]
    int mx = max(fim1, fim2);
        ^~
lot.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &l);
  ~~~~~^~~~~~~~~~~~~~~~~
lot.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &v[i]);
   ~~~~~^~~~~~~~~~~~~
lot.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &q);
  ~~~~~^~~~~~~~~~
lot.cpp:44:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &r);
   ~~~~~^~~~~~~~~~
lot.cpp:8:13: warning: 'n' is used uninitialized in this function [-Wuninitialized]
  int id = n - l + 1;
           ~~^~~
lot.cpp:8:13: warning: 'l' is used uninitialized in this function [-Wuninitialized]
#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...