Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- int main() {
- std::ios_base::sync_with_stdio(false);
- std::cin.tie(NULL);
- int chunks_on_cluster;
- int servers_cnt;
- int requests_cnt;
- std::cin >> chunks_on_cluster >> servers_cnt >> requests_cnt;
- std::vector<int> chunks(chunks_on_cluster, 0);
- for (int i = 0; i < chunks_on_cluster; ++i) {
- std::cin >> chunks[i];
- }
- std::string result;
- result.resize(requests_cnt * 2);
- for (int i = 0; i < requests_cnt; ++i) {
- int from, to, first, last;
- std::cin >> from >> to >> first >> last;
- bool can_do_request = true;
- for (int j = first - 1; j < last; ++j) {
- can_do_request = can_do_request && chunks[j] == from;
- }
- if (can_do_request) {
- for (int j = first - 1; j < last; ++j) {
- chunks[j] = to;
- }
- result[2 * i] = '1';
- } else {
- result[2 * i] = '0';
- }
- result[2 * i + 1] = '\n';
- }
- std::cout << result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement