Submission #919733

#TimeUsernameProblemLanguageResultExecution timeMemory
919733TINRelativnost (COCI15_relativnost)C++17
0 / 140
4042 ms35856 KiB
#include <bits/stdc++.h> using namespace std; #define FNAME "test" typedef long long ll; const ll M = 10007; const int N = 1e5 + 5; const int C = 21; int n, c, q; ll a[N], b[N]; struct Node { ll chosen[C]; Node() { memset(chosen, 0, sizeof(chosen)); } Node(ll a, ll b) { memset(chosen, 0, sizeof(chosen)); chosen[0] = b; chosen[1] = a; } Node operator + (const Node& oth) { Node nNode; for (int i = 0; i <= c; i++) { for (int j = 0; j <= c; j++) { nNode.chosen[min(c, i + j)] = (nNode.chosen[min(c, i + j)] + chosen[i] * oth.chosen[j]) % M; } } return nNode; } } ST[2 * N]; void Task() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout << fixed << setprecision(9); if (fopen(FNAME".inp","r")) { freopen(FNAME".inp","r",stdin); freopen(FNAME".out","w",stdout); } } void update(int pos, const Node& value) { for (ST[pos += n] = value; pos >>= 1;) ST[pos] = ST[pos << 1] + ST[pos << 1 | 1]; } ll query(int l, int r) { Node res = ST[l + n]; for (int i = l + 1; i <= r; i++) res = res + ST[i + n]; return res.chosen[c]; } void Solve() { //Your Code cin >> n >> c; for (int i = 0; i < n; i++) cin >> a[i] >> b[i], update(i, Node(a[i], b[i])); cin >> q; while (q--) { int pos; ll vala, valb; cin >> pos >> vala >> valb; pos--; a[pos] = vala, b[pos] = valb; update(pos, Node(vala, valb)); cout << query(0, n - 1) << '\n'; } } int main() { Task(); Solve(); cerr << "\nTime run: " << 1000*clock()/CLOCKS_PER_SEC << "ms"; return 37^37; }

Compilation message (stderr)

relativnost.cpp: In function 'void Task()':
relativnost.cpp:45:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |   freopen(FNAME".inp","r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
relativnost.cpp:46:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |   freopen(FNAME".out","w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...