Submission #240675

#TimeUsernameProblemLanguageResultExecution timeMemory
240675m3r8Lottery (CEOI18_lot)C++14
35 / 100
485 ms4476 KiB
#include <stdio.h> #include <algorithm> #include <utility> #include <functional> #include <vector> #define N 10010 #define ii std::pair<int,int> int dp[N][102]; int map[N]; int seq[N]; std::vector<ii> qry; std::vector<int> qrr; int main(void){ int n,l,q; scanf("%d %d",&n,&l); for(int i = 0;i<n;i++){ scanf("%d",&seq[i]); }; scanf("%d",&q); int v; for(int i = 0;i<q;i++){ scanf("%d",&v); qry.push_back({v,i}); qrr.push_back(v); }; std::sort(qry.begin(),qry.end(),std::less<ii>()); int idx = 0; for(int i = 0;i<=l;i++){ if(idx >= qry.size()){ map[i] = idx; }else if(qry[idx].first >= i){ map[i] = idx; }else{ idx++; map[i] = idx; }; }; for(int i = 1;i<n-l+1;i++){ int tmp = 0; for(int j = 0;j<n-i;j++){ if(j < l){ tmp += seq[j] != seq[j+i]; if(j == l-1){ dp[0][map[tmp]]++; dp[i][map[tmp]]++; }; }else{ tmp -= seq[j-l] != seq[j+i-l]; tmp += seq[j] != seq[j+i]; dp[j-l+1][map[tmp]]++; dp[j-l+i+1][map[tmp]]++; }; }; }; for(int i = 0;i<n-l+1;i++){ for(int j = 1;j<q;j++){ dp[i][j] += dp[i][j-1]; }; }; for(int j = 0;j<qry.size();j++){ for(int i = 0;i<n-l+1;i++){ printf("%d ",dp[i][j]); }; puts(""); }; return 0; };

Compilation message (stderr)

lot.cpp: In function 'int main()':
lot.cpp:35:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(idx >= qry.size()){
        ~~~~^~~~~~~~~~~~~
lot.cpp:70:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0;j<qry.size();j++){
                 ~^~~~~~~~~~~
lot.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&n,&l);
   ~~~~~^~~~~~~~~~~~~~~
lot.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&seq[i]);  
     ~~~~~^~~~~~~~~~~~~~
lot.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&q);
   ~~~~~^~~~~~~~~
lot.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&v);
     ~~~~~^~~~~~~~~
#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...