Submission #336034

# Submission time Handle Problem Language Result Execution time Memory
336034 2020-12-14T14:17:02 Z knightron0 Dreaming (IOI13_dreaming) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "dreaming.h"
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define printvector(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl;
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define int long long int
#define ull unsigned long long
#define printarray(arr, n) for(int i= 0;i<n;i++) cout<<arr[i]<<' '; cout<<endl;
#define printvecpairs(vec) for(auto it: vec) cout<<it.fr<<' '<<it.sc<<endl;
#define initdp(a) memset(a, -1, sizeof(a));
#define endl '\n'
#define float long double

using namespace std;
const int MOD = 1e9 + 7;
const int INF = 2e15;
const int MAXN = 1e5 + 5;

int dist[MAXN];
vector<pair<int, int> > adj[MAXN];
int n, m, k;
int mx;
int val;
bool vis[MAXN][10]; 
vector<int> nice;

void dfs(int s, int curr, int fl, bool ad){

	vis[s][fl] = true;
    if(curr >= mx){
        mx = curr;
        val = s;
    }
    if(ad){
        dist[s] = max(curr, dist[s]);
    } else {
        nice.pb(s);
    }
	for(auto it: adj[s]){
		if(!vis[it.fr][fl]){
			dfs(it.fr, curr + it.sc, fl, ad);
		}
	}
}
int travelTime(int N,int M,int L, int A[],int B[],int T[]){
    n = N; m = M; k = L;
    for(int i= 0;i<m;i++){
        adj[A[i]].pb(mp(B[i], T[i]));
        adj[B[i]].pb(mp(A[i], T[i]));
    }
    clr(dist);
    vector<pair<int, int> > vec;
    for(int i = 0;i<n;i++){
        if(vis[i][0]) continue;
        nice.clear();
        mx = 0;
        val = -1;
        dfs(i, 0, 0, 0);
        int d1 = val;
        mx = 0;
        val = -1;
        dfs(d1, 0, 1, 1);
        int d2 = val;
        mx = 0;
        val = -1;
        dfs(d2, 0, 2, 1);
        int ok = 0;
        int mxval=INT_MAX;
        for(int j: nice){
            if(dist[j] <= mxval){
                mxval = dist[j];
                ok = j;
            }
        }
        vec.pb(mp(dist[ok], ok));
    }
    sort(all(vec));
    reverse(all(vec));
    for(int i= 1;i<vec.size();i++){
        adj[vec[0].sc].pb(mp(vec[i].sc, k));
    }
    mx = 0;
    val = -1;
    dfs(1, 0, 4, 0);
    int d1 = val; mx = 0; val = -1;
    dfs(d1, 0, 5, 1);
    return mx;
}
// signed main() {
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // #endif
    
//     return 0;
// }



Compilation message

dreaming.cpp: In function 'long long int travelTime(long long int, long long int, long long int, long long int*, long long int*, long long int*)':
dreaming.cpp:92:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   92 |     for(int i= 1;i<vec.size();i++){
      |                  ~^~~~~~~~~~~
/tmp/ccZL1VyE.o: In function `main':
grader.c:(.text.startup+0xc9): undefined reference to `travelTime'
collect2: error: ld returned 1 exit status