Submission #31678

#TimeUsernameProblemLanguageResultExecution timeMemory
31678long10024070Relativnost (COCI15_relativnost)C++11
112 / 140
4000 ms19364 KiB
#include <iostream> #include <cstdio> using namespace std; const string TASK = "Relativnost"; const int Mod = 1e4 + 7; const int maxn = 1e5 + 1; int n,c,i,a[maxn],b[maxn],node[maxn*2][21],t,j,k; void Enter() { scanf("%d%d",&n,&c); for (i=1;i<=n;++i) scanf("%d",&a[i]); for (i=1;i<=n;++i) scanf("%d",&b[i]); } void Update() { t = i + n - 1; for (j=2;j<=c;++j) node[t][j] = 0; node[t][1] = a[i] % Mod; node[t][0] = b[i] % Mod; t >>= 1; while (t != 0) { for (j=0;j<=c;++j) node[t][j] = 0; for (j=0;j<=c;++j) for (k=0;k<=c;++k) { node[t][min(c,j+k)] = (node[t][min(c,j+k)] + node[t*2][j] * node[t*2+1][k]) % Mod; } t >>= 1; } } void Init() { for (i=1;i<=n;++i) Update(); } void Solve() { int q,A,B; for (scanf("%d",&q);q>0;--q) { scanf("%d",&i); scanf("%d%d",&a[i],&b[i]); Update(); printf("%d\n",node[1][c]); } } int main() { ios_base::sync_with_stdio(false); //cin.tie(NULL); //cout.tie(NULL); //freopen((TASK+".INP").c_str(),"r",stdin); //freopen((TASK+".OUT").c_str(),"w",stdout); Enter(); Init(); Solve(); }

Compilation message (stderr)

relativnost.cpp: In function 'void Solve()':
relativnost.cpp:47:11: warning: unused variable 'A' [-Wunused-variable]
     int q,A,B;
           ^
relativnost.cpp:47:13: warning: unused variable 'B' [-Wunused-variable]
     int q,A,B;
             ^
relativnost.cpp: In function 'void Enter()':
relativnost.cpp:13:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&c);
                        ^
relativnost.cpp:15:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a[i]);
                          ^
relativnost.cpp:17:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&b[i]);
                          ^
relativnost.cpp: In function 'void Solve()':
relativnost.cpp:48:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (scanf("%d",&q);q>0;--q) {
                        ^
relativnost.cpp:49:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&i);
                       ^
relativnost.cpp:50:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&a[i],&b[i]);
                                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...