diff options
author | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-10-05 21:49:54 +0200 |
---|---|---|
committer | Franciszek Malinka <franciszek.malinka@gmail.com> | 2021-10-05 21:49:54 +0200 |
commit | c5fcf7179a83ef65c86c6a4a390029149e518649 (patch) | |
tree | d29ffc5b86a0d257453cedcf87d91a13d8bf3b0d /Semestr 4/aisd/pracownia4/brut.cpp | |
parent | f8a88b6a4aba1f66d04711a9330eaba49a50c463 (diff) |
Duzy commit ze smieciami
Diffstat (limited to 'Semestr 4/aisd/pracownia4/brut.cpp')
-rw-r--r-- | Semestr 4/aisd/pracownia4/brut.cpp | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/Semestr 4/aisd/pracownia4/brut.cpp b/Semestr 4/aisd/pracownia4/brut.cpp deleted file mode 100644 index 32f4ebb..0000000 --- a/Semestr 4/aisd/pracownia4/brut.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include <bits/stdc++.h> -using namespace std; -typedef long long ll; - -struct insert_list { - vector<int> v; - - insert_list() { - } - - void insert(int p, int val) { - assert(p <= v.size()); - assert(p >= 0); - vector<int> temp; - for (int i = 0; i < p; i++) { - temp.push_back(v[i]); - } - temp.push_back(val); - for (int i = p; i < v.size(); i++) { - temp.push_back(v[i]); - } - v = temp; - } - - void erase(int p) { - assert(p <= v.size()); - assert(p >= 1); - vector<int> temp; - for (int i = 0; i < p-1; i++) { - temp.push_back(v[i]); - } - for (int i = p; i < v.size(); i++) { - temp.push_back(v[i]); - } - v = temp; - } - - ll sum(int l, int r) { - ll ans = 0; - for (int i = l-1; i < r; i++) { - ans += v[i]; - } - return ans; - } -}; - -insert_list v; - -int main() { - ios_base::sync_with_stdio(false); - cin.tie(); - int n; - cin >> n; - for (int i = 0; i < n; i++) { - char c; - cin >> c; - if (c == 'D') { - int a; - cin >> a; - v.erase(a); - } - else { - int a, b; - cin >> a >> b; - if (c == 'I') v.insert(a, b); - else cout << v.sum(a,b) << "\n"; - } - } -}
\ No newline at end of file |