Submission #1092131

#TimeUsernameProblemLanguageResultExecution timeMemory
1092131underwaterkillerwhaleSplit the sequence (APIO14_sequence)C++17
0 / 100
2 ms348 KiB
#include <bits/stdc++.h> #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define rep(i,m,n) for(int i=(m); i<=(n); i++) #define reb(i,m,n) for(int i=(m); i>=(n); i--) #define iter(id, v) for(auto id : v) #define fs first #define se second #define MP make_pair #define pb push_back #define bit(msk, i) ((msk >> i) & 1) #define SZ(v) (int)v.size() #define ALL(v) v.begin(),v.end() using namespace std; mt19937_64 rd(chrono :: steady_clock :: now ().time_since_epoch().count()); ll Rand (ll l, ll r) { return uniform_int_distribution<ll> (l, r) (rd); } const int N = 1e5 + 7; const int Mod = 1e9 + 7; ///loonf mod sai const int INF = 1e9; const ll BASE = 137; const int szBL = 350; inline void Add (int &A, int B) { A += B; if (A >= Mod) A -= Mod; } int n; ll K; int a[N]; unordered_map<int,int> dp[35]; int f[35]; void solution() { cin >> n >> K; rep (i, 1, n) cin >> a[i]; rep (i, 1, n) { dp[1][a[i]]++; if (a[i] % K != 0) continue; int delta = a[i] / K; rep (j, 2, 31) { Add(dp[j][a[i]], dp[j - 1][delta]); Add(f[j], dp[j - 1][delta]); } } rep (i, 2, n) { if (i > 31) cout << 0 <<" "; else cout << f[i] <<" "; } } #define file(name) freopen(name".inp","r",stdin); \ freopen(name".out","w",stdout); int main () { file("maxgp"); ios_base :: sync_with_stdio(false); cin.tie(0); cout.tie(0); int num_Test = 1; // cin >> num_Test; while (num_Test--) solution(); } /* no bug +8 chu y break hay return se lam hong logic xet transition cua i va i + 1 construct ket qua chu y truong hop : KHONG CO GI ko làm được hướng 1: đổi hướng làm hướng 2: đưa ra nhận xét 2 3 2 0 0 1 0 1 1 0 1 0 2 1 2 0 5 5 0 */

Compilation message (stderr)

sequence.cpp: In function 'int main()':
sequence.cpp:53:27: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 | #define file(name) freopen(name".inp","r",stdin); \
      |                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
sequence.cpp:56:5: note: in expansion of macro 'file'
   56 |     file("maxgp");
      |     ^~~~
sequence.cpp:54:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 | freopen(name".out","w",stdout);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
sequence.cpp:56:5: note: in expansion of macro 'file'
   56 |     file("maxgp");
      |     ^~~~
#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...