답안 #351846

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
351846 2021-01-20T08:45:12 Z beksultan04 Shortcut (IOI16_shortcut) C++14
0 / 100
2000 ms 24044 KB
#include "shortcut.h"
#ifndef EVAL
#include "grader.cpp"
#endif // EVAL
#include <bits/stdc++.h>
using namespace std;
#define lol long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scanl(a) scanf("%lld",&a);
#define scanll(a,b) scanf("%lld %lld",&a, &b);
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
#define eps 1e-12
const lol INF = 1e17+1;
lol dia,iz,dis[1000001];
vector <pair<int,lol>> g[1000001];

lol find_shortcut(int n, vector<int> l, vector<int> d, int c){
    int i,j,x=0,y=0,pos=0;
    lol ans = -1,mx = 0,res=INF;
    vector <pair<lol,pii> > v;

    for (i=0;i<n;++i){
        g[i].pb({i+n,d[i]});
        g[i+n].pb({i,d[i]});
        if (i+1 < n){
            g[i].pb({i+1,l[i]});
            g[i+1].pb({i,l[i]});
        }
    }

    for (i=0;i<n;++i){
        mx = d[i];
        for (j=i+1;j<n;++j){
            mx += l[j-1];
            v.pb({mx,{i,j}});
            if (mx+d[j] > ans){
                ans = mx+d[j];
                x = i;
                y = j;
            }
        }
    }
    sort(allr(v));
    for (int h=0;h<=v.size()/2;++h){
        x = v[h].sc.fr;
        y = v[h].sc.sc;
        ans = 0;
        g[x].pb({y,c});
        g[y].pb({x,c});
        for (int start = 0;start < 2*n;++start){
            priority_queue <pair<lol,int>> s;
            for (i=0;i<n*2;++i)dis[i] = INF;
            s.push({0,start});
            dis[start] = 0;
            while (!s.empty()){
                int xx = s.top().sc;
                s.pop();
                for (pair<int,lol> to: g[xx]){
                    if (to.sc+dis[xx] < dis[to.fr]){
                        dis[to.fr] = to.sc+dis[xx];
                        s.push({-dis[to.fr],to.fr});
                    }
                }
            }
            for (i=0;i<n*2;++i){
                if (dis[i] > ans && dis[i] != INF){
                    ans = dis[i];
                }
            }
        }
        g[x].pop_back();
        g[y].pop_back();
        res = min(res,ans);

    }

    ret res;
}

Compilation message

shortcut.cpp: In function 'long long int find_shortcut(int, std::vector<int>, std::vector<int>, int)':
shortcut.cpp:58:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for (int h=0;h<=v.size()/2;++h){
      |                  ~^~~~~~~~~~~~
shortcut.cpp:32:21: warning: unused variable 'pos' [-Wunused-variable]
   32 |     int i,j,x=0,y=0,pos=0;
      |                     ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 23788 KB n = 4, 80 is a correct answer
2 Correct 17 ms 23788 KB n = 9, 110 is a correct answer
3 Correct 17 ms 23788 KB n = 4, 21 is a correct answer
4 Correct 21 ms 23936 KB n = 3, 4 is a correct answer
5 Correct 17 ms 23788 KB n = 2, 62 is a correct answer
6 Correct 17 ms 23788 KB n = 2, 3 is a correct answer
7 Correct 19 ms 23788 KB n = 3, 29 is a correct answer
8 Correct 16 ms 23788 KB n = 2, 3 is a correct answer
9 Correct 18 ms 23916 KB n = 2, 3 is a correct answer
10 Correct 16 ms 23788 KB n = 2, 2000000001 is a correct answer
11 Correct 17 ms 23788 KB n = 2, 3000000000 is a correct answer
12 Correct 16 ms 23788 KB n = 3, 3000000000 is a correct answer
13 Correct 16 ms 23788 KB n = 3, 3000000000 is a correct answer
14 Correct 16 ms 23788 KB n = 4, 3000000001 is a correct answer
15 Correct 17 ms 23788 KB n = 4, 4000000000 is a correct answer
16 Correct 17 ms 23788 KB n = 5, 4000000000 is a correct answer
17 Correct 17 ms 23916 KB n = 10, 1000000343 is a correct answer
18 Correct 17 ms 23916 KB n = 10, 3189 is a correct answer
19 Correct 17 ms 23788 KB n = 10, 7000000000 is a correct answer
20 Correct 17 ms 23788 KB n = 5, 12 is a correct answer
21 Correct 18 ms 23788 KB n = 5, 25 is a correct answer
22 Correct 17 ms 23788 KB n = 2, 122 is a correct answer
23 Correct 17 ms 23788 KB n = 10, 117 is a correct answer
24 Correct 19 ms 23788 KB n = 10, 336 is a correct answer
25 Correct 18 ms 23788 KB n = 10, 438 is a correct answer
26 Correct 18 ms 23788 KB n = 10, 206 is a correct answer
27 Correct 17 ms 23788 KB n = 10, 636 is a correct answer
28 Correct 17 ms 23788 KB n = 4, 2399 is a correct answer
29 Correct 17 ms 23788 KB n = 10, 10992 is a correct answer
30 Correct 21 ms 23820 KB n = 10, 3112 is a correct answer
31 Execution timed out 2076 ms 24044 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 23788 KB n = 4, 80 is a correct answer
2 Correct 17 ms 23788 KB n = 9, 110 is a correct answer
3 Correct 17 ms 23788 KB n = 4, 21 is a correct answer
4 Correct 21 ms 23936 KB n = 3, 4 is a correct answer
5 Correct 17 ms 23788 KB n = 2, 62 is a correct answer
6 Correct 17 ms 23788 KB n = 2, 3 is a correct answer
7 Correct 19 ms 23788 KB n = 3, 29 is a correct answer
8 Correct 16 ms 23788 KB n = 2, 3 is a correct answer
9 Correct 18 ms 23916 KB n = 2, 3 is a correct answer
10 Correct 16 ms 23788 KB n = 2, 2000000001 is a correct answer
11 Correct 17 ms 23788 KB n = 2, 3000000000 is a correct answer
12 Correct 16 ms 23788 KB n = 3, 3000000000 is a correct answer
13 Correct 16 ms 23788 KB n = 3, 3000000000 is a correct answer
14 Correct 16 ms 23788 KB n = 4, 3000000001 is a correct answer
15 Correct 17 ms 23788 KB n = 4, 4000000000 is a correct answer
16 Correct 17 ms 23788 KB n = 5, 4000000000 is a correct answer
17 Correct 17 ms 23916 KB n = 10, 1000000343 is a correct answer
18 Correct 17 ms 23916 KB n = 10, 3189 is a correct answer
19 Correct 17 ms 23788 KB n = 10, 7000000000 is a correct answer
20 Correct 17 ms 23788 KB n = 5, 12 is a correct answer
21 Correct 18 ms 23788 KB n = 5, 25 is a correct answer
22 Correct 17 ms 23788 KB n = 2, 122 is a correct answer
23 Correct 17 ms 23788 KB n = 10, 117 is a correct answer
24 Correct 19 ms 23788 KB n = 10, 336 is a correct answer
25 Correct 18 ms 23788 KB n = 10, 438 is a correct answer
26 Correct 18 ms 23788 KB n = 10, 206 is a correct answer
27 Correct 17 ms 23788 KB n = 10, 636 is a correct answer
28 Correct 17 ms 23788 KB n = 4, 2399 is a correct answer
29 Correct 17 ms 23788 KB n = 10, 10992 is a correct answer
30 Correct 21 ms 23820 KB n = 10, 3112 is a correct answer
31 Execution timed out 2076 ms 24044 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 23788 KB n = 4, 80 is a correct answer
2 Correct 17 ms 23788 KB n = 9, 110 is a correct answer
3 Correct 17 ms 23788 KB n = 4, 21 is a correct answer
4 Correct 21 ms 23936 KB n = 3, 4 is a correct answer
5 Correct 17 ms 23788 KB n = 2, 62 is a correct answer
6 Correct 17 ms 23788 KB n = 2, 3 is a correct answer
7 Correct 19 ms 23788 KB n = 3, 29 is a correct answer
8 Correct 16 ms 23788 KB n = 2, 3 is a correct answer
9 Correct 18 ms 23916 KB n = 2, 3 is a correct answer
10 Correct 16 ms 23788 KB n = 2, 2000000001 is a correct answer
11 Correct 17 ms 23788 KB n = 2, 3000000000 is a correct answer
12 Correct 16 ms 23788 KB n = 3, 3000000000 is a correct answer
13 Correct 16 ms 23788 KB n = 3, 3000000000 is a correct answer
14 Correct 16 ms 23788 KB n = 4, 3000000001 is a correct answer
15 Correct 17 ms 23788 KB n = 4, 4000000000 is a correct answer
16 Correct 17 ms 23788 KB n = 5, 4000000000 is a correct answer
17 Correct 17 ms 23916 KB n = 10, 1000000343 is a correct answer
18 Correct 17 ms 23916 KB n = 10, 3189 is a correct answer
19 Correct 17 ms 23788 KB n = 10, 7000000000 is a correct answer
20 Correct 17 ms 23788 KB n = 5, 12 is a correct answer
21 Correct 18 ms 23788 KB n = 5, 25 is a correct answer
22 Correct 17 ms 23788 KB n = 2, 122 is a correct answer
23 Correct 17 ms 23788 KB n = 10, 117 is a correct answer
24 Correct 19 ms 23788 KB n = 10, 336 is a correct answer
25 Correct 18 ms 23788 KB n = 10, 438 is a correct answer
26 Correct 18 ms 23788 KB n = 10, 206 is a correct answer
27 Correct 17 ms 23788 KB n = 10, 636 is a correct answer
28 Correct 17 ms 23788 KB n = 4, 2399 is a correct answer
29 Correct 17 ms 23788 KB n = 10, 10992 is a correct answer
30 Correct 21 ms 23820 KB n = 10, 3112 is a correct answer
31 Execution timed out 2076 ms 24044 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 23788 KB n = 4, 80 is a correct answer
2 Correct 17 ms 23788 KB n = 9, 110 is a correct answer
3 Correct 17 ms 23788 KB n = 4, 21 is a correct answer
4 Correct 21 ms 23936 KB n = 3, 4 is a correct answer
5 Correct 17 ms 23788 KB n = 2, 62 is a correct answer
6 Correct 17 ms 23788 KB n = 2, 3 is a correct answer
7 Correct 19 ms 23788 KB n = 3, 29 is a correct answer
8 Correct 16 ms 23788 KB n = 2, 3 is a correct answer
9 Correct 18 ms 23916 KB n = 2, 3 is a correct answer
10 Correct 16 ms 23788 KB n = 2, 2000000001 is a correct answer
11 Correct 17 ms 23788 KB n = 2, 3000000000 is a correct answer
12 Correct 16 ms 23788 KB n = 3, 3000000000 is a correct answer
13 Correct 16 ms 23788 KB n = 3, 3000000000 is a correct answer
14 Correct 16 ms 23788 KB n = 4, 3000000001 is a correct answer
15 Correct 17 ms 23788 KB n = 4, 4000000000 is a correct answer
16 Correct 17 ms 23788 KB n = 5, 4000000000 is a correct answer
17 Correct 17 ms 23916 KB n = 10, 1000000343 is a correct answer
18 Correct 17 ms 23916 KB n = 10, 3189 is a correct answer
19 Correct 17 ms 23788 KB n = 10, 7000000000 is a correct answer
20 Correct 17 ms 23788 KB n = 5, 12 is a correct answer
21 Correct 18 ms 23788 KB n = 5, 25 is a correct answer
22 Correct 17 ms 23788 KB n = 2, 122 is a correct answer
23 Correct 17 ms 23788 KB n = 10, 117 is a correct answer
24 Correct 19 ms 23788 KB n = 10, 336 is a correct answer
25 Correct 18 ms 23788 KB n = 10, 438 is a correct answer
26 Correct 18 ms 23788 KB n = 10, 206 is a correct answer
27 Correct 17 ms 23788 KB n = 10, 636 is a correct answer
28 Correct 17 ms 23788 KB n = 4, 2399 is a correct answer
29 Correct 17 ms 23788 KB n = 10, 10992 is a correct answer
30 Correct 21 ms 23820 KB n = 10, 3112 is a correct answer
31 Execution timed out 2076 ms 24044 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 23788 KB n = 4, 80 is a correct answer
2 Correct 17 ms 23788 KB n = 9, 110 is a correct answer
3 Correct 17 ms 23788 KB n = 4, 21 is a correct answer
4 Correct 21 ms 23936 KB n = 3, 4 is a correct answer
5 Correct 17 ms 23788 KB n = 2, 62 is a correct answer
6 Correct 17 ms 23788 KB n = 2, 3 is a correct answer
7 Correct 19 ms 23788 KB n = 3, 29 is a correct answer
8 Correct 16 ms 23788 KB n = 2, 3 is a correct answer
9 Correct 18 ms 23916 KB n = 2, 3 is a correct answer
10 Correct 16 ms 23788 KB n = 2, 2000000001 is a correct answer
11 Correct 17 ms 23788 KB n = 2, 3000000000 is a correct answer
12 Correct 16 ms 23788 KB n = 3, 3000000000 is a correct answer
13 Correct 16 ms 23788 KB n = 3, 3000000000 is a correct answer
14 Correct 16 ms 23788 KB n = 4, 3000000001 is a correct answer
15 Correct 17 ms 23788 KB n = 4, 4000000000 is a correct answer
16 Correct 17 ms 23788 KB n = 5, 4000000000 is a correct answer
17 Correct 17 ms 23916 KB n = 10, 1000000343 is a correct answer
18 Correct 17 ms 23916 KB n = 10, 3189 is a correct answer
19 Correct 17 ms 23788 KB n = 10, 7000000000 is a correct answer
20 Correct 17 ms 23788 KB n = 5, 12 is a correct answer
21 Correct 18 ms 23788 KB n = 5, 25 is a correct answer
22 Correct 17 ms 23788 KB n = 2, 122 is a correct answer
23 Correct 17 ms 23788 KB n = 10, 117 is a correct answer
24 Correct 19 ms 23788 KB n = 10, 336 is a correct answer
25 Correct 18 ms 23788 KB n = 10, 438 is a correct answer
26 Correct 18 ms 23788 KB n = 10, 206 is a correct answer
27 Correct 17 ms 23788 KB n = 10, 636 is a correct answer
28 Correct 17 ms 23788 KB n = 4, 2399 is a correct answer
29 Correct 17 ms 23788 KB n = 10, 10992 is a correct answer
30 Correct 21 ms 23820 KB n = 10, 3112 is a correct answer
31 Execution timed out 2076 ms 24044 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 23788 KB n = 4, 80 is a correct answer
2 Correct 17 ms 23788 KB n = 9, 110 is a correct answer
3 Correct 17 ms 23788 KB n = 4, 21 is a correct answer
4 Correct 21 ms 23936 KB n = 3, 4 is a correct answer
5 Correct 17 ms 23788 KB n = 2, 62 is a correct answer
6 Correct 17 ms 23788 KB n = 2, 3 is a correct answer
7 Correct 19 ms 23788 KB n = 3, 29 is a correct answer
8 Correct 16 ms 23788 KB n = 2, 3 is a correct answer
9 Correct 18 ms 23916 KB n = 2, 3 is a correct answer
10 Correct 16 ms 23788 KB n = 2, 2000000001 is a correct answer
11 Correct 17 ms 23788 KB n = 2, 3000000000 is a correct answer
12 Correct 16 ms 23788 KB n = 3, 3000000000 is a correct answer
13 Correct 16 ms 23788 KB n = 3, 3000000000 is a correct answer
14 Correct 16 ms 23788 KB n = 4, 3000000001 is a correct answer
15 Correct 17 ms 23788 KB n = 4, 4000000000 is a correct answer
16 Correct 17 ms 23788 KB n = 5, 4000000000 is a correct answer
17 Correct 17 ms 23916 KB n = 10, 1000000343 is a correct answer
18 Correct 17 ms 23916 KB n = 10, 3189 is a correct answer
19 Correct 17 ms 23788 KB n = 10, 7000000000 is a correct answer
20 Correct 17 ms 23788 KB n = 5, 12 is a correct answer
21 Correct 18 ms 23788 KB n = 5, 25 is a correct answer
22 Correct 17 ms 23788 KB n = 2, 122 is a correct answer
23 Correct 17 ms 23788 KB n = 10, 117 is a correct answer
24 Correct 19 ms 23788 KB n = 10, 336 is a correct answer
25 Correct 18 ms 23788 KB n = 10, 438 is a correct answer
26 Correct 18 ms 23788 KB n = 10, 206 is a correct answer
27 Correct 17 ms 23788 KB n = 10, 636 is a correct answer
28 Correct 17 ms 23788 KB n = 4, 2399 is a correct answer
29 Correct 17 ms 23788 KB n = 10, 10992 is a correct answer
30 Correct 21 ms 23820 KB n = 10, 3112 is a correct answer
31 Execution timed out 2076 ms 24044 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 23788 KB n = 4, 80 is a correct answer
2 Correct 17 ms 23788 KB n = 9, 110 is a correct answer
3 Correct 17 ms 23788 KB n = 4, 21 is a correct answer
4 Correct 21 ms 23936 KB n = 3, 4 is a correct answer
5 Correct 17 ms 23788 KB n = 2, 62 is a correct answer
6 Correct 17 ms 23788 KB n = 2, 3 is a correct answer
7 Correct 19 ms 23788 KB n = 3, 29 is a correct answer
8 Correct 16 ms 23788 KB n = 2, 3 is a correct answer
9 Correct 18 ms 23916 KB n = 2, 3 is a correct answer
10 Correct 16 ms 23788 KB n = 2, 2000000001 is a correct answer
11 Correct 17 ms 23788 KB n = 2, 3000000000 is a correct answer
12 Correct 16 ms 23788 KB n = 3, 3000000000 is a correct answer
13 Correct 16 ms 23788 KB n = 3, 3000000000 is a correct answer
14 Correct 16 ms 23788 KB n = 4, 3000000001 is a correct answer
15 Correct 17 ms 23788 KB n = 4, 4000000000 is a correct answer
16 Correct 17 ms 23788 KB n = 5, 4000000000 is a correct answer
17 Correct 17 ms 23916 KB n = 10, 1000000343 is a correct answer
18 Correct 17 ms 23916 KB n = 10, 3189 is a correct answer
19 Correct 17 ms 23788 KB n = 10, 7000000000 is a correct answer
20 Correct 17 ms 23788 KB n = 5, 12 is a correct answer
21 Correct 18 ms 23788 KB n = 5, 25 is a correct answer
22 Correct 17 ms 23788 KB n = 2, 122 is a correct answer
23 Correct 17 ms 23788 KB n = 10, 117 is a correct answer
24 Correct 19 ms 23788 KB n = 10, 336 is a correct answer
25 Correct 18 ms 23788 KB n = 10, 438 is a correct answer
26 Correct 18 ms 23788 KB n = 10, 206 is a correct answer
27 Correct 17 ms 23788 KB n = 10, 636 is a correct answer
28 Correct 17 ms 23788 KB n = 4, 2399 is a correct answer
29 Correct 17 ms 23788 KB n = 10, 10992 is a correct answer
30 Correct 21 ms 23820 KB n = 10, 3112 is a correct answer
31 Execution timed out 2076 ms 24044 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 23788 KB n = 4, 80 is a correct answer
2 Correct 17 ms 23788 KB n = 9, 110 is a correct answer
3 Correct 17 ms 23788 KB n = 4, 21 is a correct answer
4 Correct 21 ms 23936 KB n = 3, 4 is a correct answer
5 Correct 17 ms 23788 KB n = 2, 62 is a correct answer
6 Correct 17 ms 23788 KB n = 2, 3 is a correct answer
7 Correct 19 ms 23788 KB n = 3, 29 is a correct answer
8 Correct 16 ms 23788 KB n = 2, 3 is a correct answer
9 Correct 18 ms 23916 KB n = 2, 3 is a correct answer
10 Correct 16 ms 23788 KB n = 2, 2000000001 is a correct answer
11 Correct 17 ms 23788 KB n = 2, 3000000000 is a correct answer
12 Correct 16 ms 23788 KB n = 3, 3000000000 is a correct answer
13 Correct 16 ms 23788 KB n = 3, 3000000000 is a correct answer
14 Correct 16 ms 23788 KB n = 4, 3000000001 is a correct answer
15 Correct 17 ms 23788 KB n = 4, 4000000000 is a correct answer
16 Correct 17 ms 23788 KB n = 5, 4000000000 is a correct answer
17 Correct 17 ms 23916 KB n = 10, 1000000343 is a correct answer
18 Correct 17 ms 23916 KB n = 10, 3189 is a correct answer
19 Correct 17 ms 23788 KB n = 10, 7000000000 is a correct answer
20 Correct 17 ms 23788 KB n = 5, 12 is a correct answer
21 Correct 18 ms 23788 KB n = 5, 25 is a correct answer
22 Correct 17 ms 23788 KB n = 2, 122 is a correct answer
23 Correct 17 ms 23788 KB n = 10, 117 is a correct answer
24 Correct 19 ms 23788 KB n = 10, 336 is a correct answer
25 Correct 18 ms 23788 KB n = 10, 438 is a correct answer
26 Correct 18 ms 23788 KB n = 10, 206 is a correct answer
27 Correct 17 ms 23788 KB n = 10, 636 is a correct answer
28 Correct 17 ms 23788 KB n = 4, 2399 is a correct answer
29 Correct 17 ms 23788 KB n = 10, 10992 is a correct answer
30 Correct 21 ms 23820 KB n = 10, 3112 is a correct answer
31 Execution timed out 2076 ms 24044 KB Time limit exceeded
32 Halted 0 ms 0 KB -