Submission #93613

#TimeUsernameProblemLanguageResultExecution timeMemory
93613BartolMRelativnost (COCI15_relativnost)C++17
140 / 140
3402 ms13152 KiB
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <vector> using namespace std; #define X first #define Y second #define mp make_pair #define pb push_back typedef long long ll; typedef pair <int, int> pii; const int INF=0x3f3f3f3f; const int N=1e5+5; const int K=25; const int MOD=10007; int n, k, off=1, q; int tour[K][3*N], A[N], B[N]; int add(int x, int y) { return (x+y)%MOD; } int mul(int x, int y) { return (x*y)%MOD; } void mrg(int l, int r, int pos) { for (int i=0; i<k; ++i) { tour[i][pos]=0; for (int j=0; j<=i; ++j) { tour[i][pos]=add(mul(tour[j][l], tour[i-j][r]), tour[i][pos]); } } tour[k][pos]=0; for (int i=0; i<=k; ++i) { for (int j=k-i; j<=k; ++j) { tour[k][pos]=add(tour[k][pos], mul(tour[i][l], tour[j][r])); } } } void update(int pos, int a, int b) { pos+=off; tour[0][pos]=b; tour[1][pos]=a; while (1) { pos/=2; if (!pos) break; mrg(pos*2, pos*2+1, pos); } } void load() { scanf("%d %d", &n, &k); while (off<n) off*=2; for (int i=0; i<n; ++i) { scanf("%d", A+i); A[i]%=MOD; tour[1][i+off]=A[i]; } for (int i=0; i<n; ++i) { scanf("%d", B+i); B[i]%=MOD; tour[0][i+off]=B[i]; } for(int i=n; i<off; ++i) tour[0][i+off] = 1; scanf("%d", &q); } void solve() { for (int i=off-1; i>0; --i) mrg(i*2, i*2+1, i); //printf("%d\n", tour[k][1]); for (int i=0; i<q; ++i) { int p, a, b; scanf("%d %d %d", &p, &a, &b); --p; update(p, a%MOD, b%MOD); printf("%d\n", tour[k][1]); } } int main() { load(); solve(); return 0; }

Compilation message (stderr)

relativnost.cpp: In function 'void load()':
relativnost.cpp:59:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~~
relativnost.cpp:62:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", A+i);
         ~~~~~^~~~~~~~~~~
relativnost.cpp:67:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", B+i);
         ~~~~~^~~~~~~~~~~
relativnost.cpp:72:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &q);
     ~~~~~^~~~~~~~~~
relativnost.cpp: In function 'void solve()':
relativnost.cpp:80:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d", &p, &a, &b); --p;
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...