Submission #31674

#TimeUsernameProblemLanguageResultExecution timeMemory
31674long10024070Relativnost (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,a[maxn],b[maxn],node[maxn*2][21],t,j,k; void Enter() { scanf("%d%d",&n,&c); for (int i=1;i<=n;++i) scanf("%d",&a[i]); for (int i=1;i<=n;++i) scanf("%d",&b[i]); } void Update(const int &i) { 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 /= 2; while (t != 0) { //fill(node[t],node[t]+c+1,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 /= 2; } } void Init() { for (int i=1;i<=n;++i) Update(i); } void Solve() { int q,p,A,B; for (scanf("%d",&q);q>0;--q) { scanf("%d%d%d",&p,&A,&B); a[p] = A; b[p] = B; Update(p); 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 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:49: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:50:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d",&p,&A,&B);
                                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...