Submission #31669

#TimeUsernameProblemLanguageResultExecution timeMemory
31669long10024070Relativnost (COCI15_relativnost)C++11
112 / 140
4000 ms19752 KiB
#include <iostream> #include <cstdio> using namespace std; const string TASK = "Relativnost"; const int Mod = 1e4 + 7; const int maxn = 1e5 + 1; struct T_node { int f[21]; }; int n,id[maxn]; int c,a[maxn],b[maxn]; T_node node[maxn*2]; void Enter() { //cin >> n >> c; scanf("%d%d",&n,&c); for (int i=1;i<=n;++i) { //cin >> a[i]; scanf("%d",&a[i]); a[i] %= Mod; } for (int i=1;i<=n;++i) { //cin >> b[i]; scanf("%d",&b[i]); b[i] %= Mod; } } void Update(const int &i) { int t = i + n - 1; fill(node[t].f,node[t].f+c+1,0); node[t].f[1] = a[i]; node[t].f[0] = b[i]; t /= 2; while (t != 0) { fill(node[t].f,node[t].f+c+1,0); for (int j=0;j<=c;++j) for (int k=0;k<=c;++k) { node[t].f[min(c,j+k)] = (node[t].f[min(c,j+k)] + node[t*2].f[j] * node[t*2+1].f[k] % Mod) % 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) { //cin >> p >> A >> B; scanf("%d%d%d",&p,&A,&B); a[p] = A % Mod; b[p] = B % Mod; Update(p); //cout << node[1].f[c] << '\n'; printf("%d\n",node[1].f[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:20: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:23:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a[i]);
                          ^
relativnost.cpp:28: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:59: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:61: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...