Submission #898788

#TimeUsernameProblemLanguageResultExecution timeMemory
898788vjudge1Valley (BOI19_valley)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define u_map unordered_map
#define  int ll
const int maxn = 1e5 + 5, mod = 1e9 + 7;

vector<pii> adj[maxn], edg;
bool sho[maxn];
map<pii, int> va;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, s, q, e;
    cin >> n >> s >> q >> e;
    for (int i = 1; i < n; i++) {
    	int u, v, w;
    	cin >> u >> v >> w;
    	adj[u].pb({w, v});
    	adj[v].pb({w, u});
    	va[{u, v}] = w;
    	va[{v, u}] = w;
    	edg.pb({u, v});
    }
    for (int i = 1; i <= s; i++) {
    	int x;
    	cin >> x;
		sho[x] = 1;    	
    }
    while (q--) {
    	int l, r;
    	cin >> l >> r;
    	if ((r <= l and e <= l) or (r > l and e > l)) {
    		cout << "escaped" << endl;
    		continue;
    	}
    	int ans1 = 0, ans2 = 0;
    	bool is1 = false, is2 = false;
    	for (int i = r; i >= max(1, l + 1); i--) {
    		if (sho[i]) {
    			is1 = true;
    			break;
    		}
    		ans1 += va[{i, i - 1}];
    	}
    	for (int i = r; i <= min({n, l}); i++) {
    		if (sho[i]) {
    			is2 = true;
    			break;
    		}
    		ans2 += va[{i, i + 1}];
    	}
    	if (!(is1 or is2)) {
    		cout << "oo" << endl;
    	} else {
    		cout << min(((is1 ^ 1) * mod) + ans1, ((is2 ^ 1) * mod) + ans2) << endl;
    	}
    }
    return 0;
}

Compilation message (stderr)

valley.cpp:5:22: error: '::main' must return 'int'
    5 | #define ll long long int
      |                      ^~~
valley.cpp:11:14: note: in expansion of macro 'll'
   11 | #define  int ll
      |              ^~
valley.cpp:18:1: note: in expansion of macro 'int'
   18 | int main() {
      | ^~~
valley.cpp: In function 'int main()':
valley.cpp:47:39: error: no matching function for call to 'max(int, long long int)'
   47 |      for (int i = r; i >= max(1, l + 1); i--) {
      |                                       ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from valley.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
valley.cpp:47:39: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   47 |      for (int i = r; i >= max(1, l + 1); i--) {
      |                                       ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from valley.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
valley.cpp:47:39: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   47 |      for (int i = r; i >= max(1, l + 1); i--) {
      |                                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from valley.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
valley.cpp:47:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   47 |      for (int i = r; i >= max(1, l + 1); i--) {
      |                                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from valley.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
valley.cpp:47:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   47 |      for (int i = r; i >= max(1, l + 1); i--) {
      |                                       ^