Submission #702311

# Submission time Handle Problem Language Result Execution time Memory
702311 2023-02-23T13:58:03 Z josanneo22 New Home (APIO18_new_home) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t = 1;
    while (t--) {
        int n, type, q;
        cin >> n >> type >> q;
        vector<int> loc(n+3), tp(n + 3), st(n + 3), ed(n + 3);
        for (int i = 0; i < n; i++) {
            cin >> loc[i] >> tp[i] >> st[i] >> ed[i];
            tp[i]--;
        }
        vector<int> cur_type(type + 5, 0);
        for (int i = 0; i < q; i++) {
            int u, ti; cin >> u >> ti;
            int ans = -1;
            vector<int> cur_type(n, 1e18 + 1);
            for (int j = 0; j < n; j++) {
                if (st[j] <= ti && ti<=ed[j]) {
                    ans = max(ans, abs(u - loc[j]));
                    cur_type[tp[j]]=min(cur_type[tp[j]],abs(u-loc[j]))
                }
            }
            int ok = 1;
            for (int p = 0; p < type; p++) {
                if (cur_type[p] == 1e18+1) ok = 0;
            }
            if (ok == 0) cout << "-1\n";
            else cout << ans << '\n';
        }
    }
}

Compilation message

new_home.cpp: In function 'int main()':
new_home.cpp:18:42: warning: overflow in conversion from 'double' to 'std::vector<int>::value_type' {aka 'int'} changes value from '1.0e+18' to '2147483647' [-Woverflow]
   18 |             vector<int> cur_type(n, 1e18 + 1);
      |                                     ~~~~~^~~
new_home.cpp:22:71: error: expected ';' before '}' token
   22 |                     cur_type[tp[j]]=min(cur_type[tp[j]],abs(u-loc[j]))
      |                                                                       ^
      |                                                                       ;
   23 |                 }
      |                 ~