Submission #90754

#TimeUsernameProblemLanguageResultExecution timeMemory
90754VinhspmCalvinball championship (CEOI15_teams)C++14
70 / 100
398 ms1044 KiB
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define FOR(a, b, c) for(int a = b; a <= c; ++a) #define pb push_back const int N = 1e4 + 5; const int mod = 1e6 + 7; int n, num; int a[N], cnt[N]; int f[2][N]; void add(int &x, int y) { x = (x + y) % mod; } signed main() { scanf("%d", &n); FOR(i, 1, n) { scanf("%d", &a[i]), cnt[ a[i] ] ++; if(cnt[ a[i] ] == 1) num ++; } int sum = 1, las = 0, nex = 1; FOR(i, 0, n) f[las][i] = 1; for(int i = n; i >= 1; --i) { FOR(j, 0, i) { add(f[nex][j], f[las][j] * j); add(f[nex][j], f[las][j + 1]); } cnt[ a[i] ] --; if(cnt[ a[i] ] == 0) num --; FOR(t, 1, a[i] - 1) { cnt[t] ++; if(cnt[t] == 1) num ++; add(sum, f[las][num]); cnt[t] --; if(cnt[t] == 0) num --; } swap(nex, las); FOR(j, 0, i) f[nex][j] = 0; } printf("%d", sum); }

Compilation message (stderr)

teams.cpp: In function 'int main()':
teams.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
teams.cpp:21:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]), cnt[ a[i] ] ++;
         ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
#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...
#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...