Submission #668743

# Submission time Handle Problem Language Result Execution time Memory
668743 2022-12-04T20:49:24 Z Bogdan1110 Dreaming (IOI13_dreaming) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define FAST {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define FILES {freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);}
#define ll long long
#define ull unsigned long long
#define pqueue priority_queue
#define pb push_back
#define fi first
#define se second
#define ld long double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) (a).begin(), (a).end()
#define mp make_pair 
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key -> # less than k
// find_by_order -> k-th element
// pq max element

const double eps = 0.00000001;
const int NMAX = 2000010;
const ll inf = LLONG_MAX/3;
const ll modi = 998244353;

int D, maks, mx;
vector<pii>al[NMAX];
int visited[NMAX], vv[NMAX];
int maksd,pret,nes,finito;

vector<int>vis;
set<int>vektor;

void dfs(int node, int dist = 0) {
    if ( visited[node] ) return;
    visited[node] = 1;
    if ( !finito )
        vektor.insert(node);
    if ( maksd ==dist ) finito = 1;
    vv[node] = 1;
    vis.pb(node);
    if ( dist > maksd) {
        maksd = dist;
        mx = node;
    }
    if ( vektor.count(node) )
        maks = min(maks, max(D-dist, dist));
    for (auto u : al[node]) {
        dfs(u.fi, u.se + dist);
    }

    if ( !finito ) vektor.erase(node);

}

int travelTime(int n,int m,int l,int A[],int B[],int T[]) {
    for (int i = 0 ; i < m; i++) {
        al[A[i]].pb({B[i],T[i]});
        al[B[i]].pb({A[i],T[i]});
    }
    vector<int>r;
    for (int i = 0 ; i < n ; i++ ) {
        if (!vv[i]) {
            maksd = -1;
            dfs(i);
            for (auto u : vis) {
                visited[u] = 0;
            }
            vis.clear();
            pret = mx;
            vektor.clear();

            maksd = -1;
            nes = 1;
            finito = 0;
            dfs(mx);
            for (auto u : vis) {
                visited[u] = 0;
            }
            vis.clear();
            nes = 0;

            maks = INT_MAX;
            D = maksd;
            //for (auto u : vektor) cout << u << ' '; cout << "#   ";
            //cout << mx << ' ' << D << endl;
            dfs(mx);
            for (auto u : vis) {
                visited[u] = 0;
            }
            vis.clear();
            vektor.clear();
            r.pb(maks);
        }
    }

    //for (auto u : r) cout << u << ' ';
    

    sort(all(r));
    vector<int>t1,t2;
    for (int i = 0 ; i < r.size() ; i++) {
        if ( i%2 == 0 ) {
            t1.pb(r[i]);
        }
        else {
            t2.pb(r[i]);
        }
    }
    reverse(all(t2));
    for (auto u : t2) t1.pb(u);

    //for (auto u : t1) cout << u << ' ';
    int res = 0;
    int tren = INT_MAX/4;
    for (int i = 0 ; i < t1.size(); i++ ) {
        res = max(res, t1[i] + l*i - tren);
        tren = min(tren, -t1[i] + l*i);
    }

    return res;
}

Compilation message

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