Advertisement
pb_jiang

ARC077B WA

Dec 1st, 2022
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.52 KB | None | 0 0
  1. // Problem: D - 11
  2. // Contest: AtCoder - AtCoder Beginner Contest 066
  3. // URL: https://atcoder.jp/contests/abc066/tasks/arc077_b
  4. // Memory Limit: 256 MB
  5. // Time Limit: 2000 ms
  6. //
  7. // Powered by CP Editor (https://cpeditor.org)
  8.  
  9. #include <assert.h>
  10. #include <bits/stdc++.h>
  11. using namespace std;
  12. #define dbg(...) logger(#__VA_ARGS__, __VA_ARGS__)
  13. template <typename... Args> void logger(string vars, Args &&... values)
  14. {
  15.     cerr << vars << " = ";
  16.     string delim = "";
  17.     (..., (cerr << delim << values, delim = ", "));
  18.     cerr << endl;
  19. }
  20.  
  21. template <class T> inline auto vv(int m) { return vector<vector<T>>(m, vector<T>(m)); }
  22. template <class T> inline auto vv(int m, int n) { return vector<vector<T>>(m, vector<T>(n)); }
  23. template <class T, T init> inline auto vv(int m) { return vector<vector<T>>(m, vector<T>(m, init)); }
  24. template <class T, T init> inline auto vv(int m, int n) { return vector<vector<T>>(m, vector<T>(n, init)); }
  25.  
  26. template <class T> using mpq = priority_queue<T, vector<T>, greater<T>>;
  27. using vi = vector<int>;
  28. using ll = long long;
  29. using pii = pair<int, int>;
  30.  
  31. int main(int argc, char **argv)
  32. {
  33.     int n;
  34.     cin >> n;
  35.     vi a(n + 1);
  36.     set<int> cnt;
  37.     int last_seg = 0;
  38.     for (int i = 0; i <= n; ++i) {
  39.         cin >> a[i];
  40.         if (cnt.count(a[i])) {
  41.             last_seg = n - i;
  42.         }
  43.         cnt.insert(a[i]);
  44.     }
  45.     dbg(last_seg);
  46.  
  47.     const int mod = int(1e9) + 7;
  48.     vi cnp1(n + 3), cnm1(n);
  49.     cnp1[0] = 1;
  50.     for (int i = 1; i < n; ++i)
  51.         for (int j = i; j > 0; --j)
  52.             cnp1[j] = (cnp1[j] + cnp1[j - 1]) % mod;
  53.     cnm1 = cnp1;
  54.     for (int j = n; j > 0; --j)
  55.         cnp1[j] = (cnp1[j] + cnp1[j - 1]) % mod;
  56.     for (int j = n + 1; j > 0; --j)
  57.         cnp1[j] = (cnp1[j] + cnp1[j - 1]) % mod;
  58.  
  59.     int k = n + 1;
  60.     vi dup(k + 1), no_dup(k + 1);
  61.     dup[1] = 0, dup[2] = 1;
  62.     auto comb = [last_seg, mod](int n, int r) {
  63.         static vi f(last_seg + 1);
  64.         if (f[0] == 0) {
  65.             f[0] = 1;
  66.             for (int i = 1; i <= last_seg; ++i)
  67.                 for (int j = i; j > 0; --j)
  68.                     f[j] = (f[j] + f[j - 1]) % mod;
  69.         }
  70.         return r <= last_seg ? f[r] : 0;
  71.     };
  72.     for (int i = 1; i <= k; ++i) {
  73.         dup[i] = (i <= 2 ? i - 1 : cnm1[i - 2]);
  74.         int repeat = comb(last_seg, i - 1);
  75.         no_dup[i] = ((ll(cnp1[i]) - dup[i] - repeat) % mod + mod) % mod;
  76.         dbg(i, dup[i], no_dup[i], repeat);
  77.         cout << (dup[i] + no_dup[i] + mod) % mod << endl;
  78.     }
  79.     return 0;
  80. };
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement