# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
793724 |
2023-07-26T05:59:08 Z |
mindiyak |
Race (IOI11_race) |
C++17 |
|
10 ms |
23764 KB |
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pi>> vvpi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (ll i = a; i < (b); i++)
#define F0R(i, a) for (ll i = 0; i < (a); i++)
#define FORd(i, a, b) for (ll i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (ll i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define len(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fst first
#define nl endl
#define sec second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ins insert
const int MOD = 1000000007;
const int MX = INT_MAX;
const int MN = INT_MIN;
#include "race.h"
void init()
{
#ifndef ONLINE_JUDGE
freopen("input.in", "r", stdin);
freopen("output.out", "w", stdout);
#endif
}
void fastIO()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
}
vvpi paths(1e6);
int ans = 1e9;
void dfs(int pos,vi visited,int cost,int counter,vi took_path){
if(cost < 0){
return;
}
if(visited[pos])return;
if(cost == 0){
// FOR(i,0,took_path.size()){
// cout << took_path[i] << " ";
// }cout << endl;
ans = min(ans,counter);
return;
}
// FOR(i,0,took_path.size()){
// cout << took_path[i] << " ";
// }cout << pos << " cost is " << cost << endl;
visited[pos] = 1;
counter ++;
took_path.pb(pos);
FOR(i,0,paths[pos].size()){
dfs(paths[pos][i].first,visited,cost-paths[pos][i].second,counter,took_path);
}
}
int best_path(int N, int K, int H[][2], int L[])
{
ans = 1e9;
FOR(i,0,N-1){
paths[H[i][0]].pb({H[i][1],L[i]});
paths[H[i][1]].pb({H[i][0],L[i]});
}
dfs(0,vi(N,0),K,0,{});
if(ans == 1e9)return -1;
return ans;
}
Compilation message
race.cpp: In function 'void dfs(int, vi, int, int, vi)':
race.cpp:18:39: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | #define FOR(i, a, b) for (ll i = a; i < (b); i++)
| ^
race.cpp:78:3: note: in expansion of macro 'FOR'
78 | FOR(i,0,paths[pos].size()){
| ^~~
race.cpp: In function 'void init()':
race.cpp:45:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
45 | freopen("input.in", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
race.cpp:46:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
46 | freopen("output.out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
23764 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
23764 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
23764 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
23764 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |