Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define MAX 1000000
- #define pb push_back
- #define pairs pair<int, int>
- #define vi vector<int>
- #define vb vector<bool>
- #define vii vector<pairs>
- #define lb lower_bound
- #define ub upper_bound
- #define lli long long int
- #define endl '\n'
- #define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
- #define Cases cout << "Case " << ++Case << ": ";
- #define __test \
- int tt; \
- int Case = 0; \
- cin >> tt; \
- while (tt--)
- #define read(x) freopen(x, "r", stdin)
- #define write(x) freopen(x, "w", stdout)
- #define InputArray(a, n) \
- for (int i = 0; i < n; i++) \
- cin >> a[i];
- #define CopyArray(a, temp, n) \
- for (int i = 0; i < n; i++) \
- temp[i] = a[i];
- #define PrintArray(a, n) \
- for (int i = 0; i < n; i++) \
- cout << a[i] << " "; \
- cout << endl;
- using namespace std;
- int arr[MAX];
- int main() {
- read("input.txt");
- write("output.txt");
- int S, B, L, R;
- while (true) {
- cin >> S;
- cin >> B;
- if(S == 0 && B == 0) {
- break;
- }
- memset(arr, 0, sizeof(arr));
- for (int i = 1; i <= B; i++) { // query
- cin >> L >> R;
- for (int i = L; i <= R; i++) {
- arr[i] = -1;
- }
- bool isPresent = false;
- int value;
- for (int i = 1; i < L; i++) {
- if(arr[i] == 0 && arr[i + 1] == -1) {
- isPresent = true;
- value = i;
- }
- }
- if(isPresent) {
- printf("%d ", value);
- } else {
- printf("* ");
- }
- isPresent = false;
- for (int i = R + 1; i <= S; i++) {
- if(arr[i] == 0) {
- isPresent = true;
- value = i;
- break;
- }
- }
- if(isPresent) {
- printf("%d\n", value);
- } else {
- printf("*\n");
- }
- }
- printf("-\n");
- }
- cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement