답안 #962287

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
962287 2024-04-13T10:05:38 Z stev2005 꿈 (IOI13_dreaming) C++17
100 / 100
287 ms 15896 KB
#include "dreaming.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn = (1<<17), inf = (1<<30);
int n, m, lprice;

struct edge{
    int ver, cost;
    edge(){
        ver = -1;
        cost = 0;
    }
    edge(int _ver, int _cost){
        ver = _ver;
        cost = _cost;
    }
    bool operator<(const edge &other) const{
        return cost > other.cost;
    }
};

struct diamgr{
    int s, f;
    int cost, sum1, sum2;
    diamgr(){
        /*mid =*/ s = f = -1;
        cost = sum1 = sum2 = -1;
    }
    diamgr(int _s, int _f, int _cost, int _sum1, int _sum2){
        s = _s;
        f = _f;
        //mid = _mid;
        cost = _cost;
        sum1 = _sum1;
        sum2 = _sum2;
    }
};

vector <edge> v[maxn];
//bool used[maxn];
bool checkver[maxn];
int parsum[maxn], parsum1[maxn], parsum2[maxn];

int anscost;
int d[maxn];
int par[maxn], costpar[maxn];


inline void init_vectors(int *a, int *b, int *t){
    for (int i = 0; i < m; ++i){
        v[a[i]].push_back(edge(b[i], t[i]));
        v[b[i]].push_back(edge(a[i], t[i]));
        //cerr << a[i] << " " << b[i] << " " << t[i] << endl;
    }
}

void check_component(int ver){
    checkver[ver] = 1;
    for (auto nb: v[ver]){
        //cerr << "ver: " << ver << " nb: " << nb.ver << "\n";
        if (!checkver[nb.ver])
            check_component(nb.ver);
    }
}

/*int Dijkstra(int beg){
    memset(used, 0, sizeof(used));
    memset(par, -1, sizeof(par));
    memset(costpar, 0, sizeof(costpar));
    used[beg] = 1;
    checkver[beg] = 1;
    for (int i = 0; i < n; ++i)
        d[i] = inf;
    d[beg] = 0;
    costpar[beg] = 0;
    par[beg] = -1;
    priority_queue<edge> q;
    q.push(edge(beg, 0));
    int lastpopped = -1;
    while (!q.empty()){
        edge cur = q.top();
        q.pop();
        lastpopped = cur.ver;
        if (cur.cost <= d[cur.ver]){
            used[cur.ver] = 1;
            checkver[cur.ver] = 1;
            for (int i = 0; i < (int)v[cur.ver].size(); ++i){
                edge nb = v[cur.ver][i];
                if (cur.cost + nb.cost < d[nb.ver]){
                    par[nb.ver] = cur.ver;
                    costpar[nb.ver] = nb.cost;
                    d[nb.ver] = cur.cost + nb.cost;
                    nb.cost = d[nb.ver];
                    q.push(nb);
                }
            }
        }
    }
    return lastpopped;
}*/

int BFS(int beg){
    //cerr << "in the bfs(): " << beg << "\n";
    unordered_set<int> used;
    used.insert(beg);
    checkver[beg] = 1;
    costpar[beg] = 0;
    par[beg] = -1;
    d[beg] = 0;
    queue<int> q;
    int maxd = 0;
    int maxver = beg;
    q.push(beg);
    //cerr << "exactly before while\n";
    while(!q.empty()){
        int ver = q.front();
        //cerr << "in while ver: " << ver << "\n";
        q.pop();
        for (int i = 0; i < (int)v[ver].size(); ++i){
            edge nb = v[ver][i];
            if (used.find(nb.ver) == used.end()){
                d[nb.ver] = d[ver] + nb.cost;
                //cerr << "nb.ver: " << nb.ver << " d[nb.ver] == " << d[nb.ver] << endl;
                if (d[nb.ver] > maxd){
                    maxd = d[nb.ver];
                    maxver = nb.ver;
                }
                costpar[nb.ver] = nb.cost;
                par[nb.ver] = ver;
                used.insert(nb.ver);
                checkver[nb.ver] = 1;
                q.push(nb.ver);
            }
        }
    }
    //cerr << "after while, maxver: " << maxver << endl;
    return maxver;
}

int init_parsums(int s, int f, int *parsum){
    int cur = f, prev = -1;
    int cnt = 1;
    while (cur != -1){
        parsum[cnt] = parsum[cnt - 1] + costpar[cur];
        cur = par[cur];
        cnt++;
    }
    return cnt;
}

pair<int, int> find_mindif(int n, int *parsum){
    if (n == 1) return {0, 0};
    if (n == 2) return {0, parsum[1]};
    int sum1 = -(1<<30) + 10, sum2 = (1<<30) - 10;
    for (int i = 0; i < n; ++i){
        int cursum1 = parsum[i];
        int cursum2 = parsum[n - 1] - parsum[i];
        if (abs(cursum2 - cursum1) < abs(sum2 - sum1)){
            sum1 = cursum1;
            sum2 = cursum2;
        }
    }
    return {sum1, sum2};
}

pair<int, int> find_gr_dim(int ver){
    //cerr << "find_gr_dim ver: " << ver << " " << v[ver].size()<< "\n";
    //check_component(ver);
    if (v[ver].size() == 0){
        return {0, 0};
    }
    int s = BFS(ver);
    int f = BFS(s);
    //cerr << "Gr. diam: " << d[f] << endl;
    memset(parsum, 0, sizeof(parsum));
    int cntver = init_parsums(s, f, parsum);
    pair<int, int> sums = find_mindif(cntver, parsum);
    //cerr << "sums: " << sums.first << " " << sums.second << "\n";
    return sums;
}

inline void subtask123(int *a, int *b, int *t){
    init_vectors(a, b, t);
    pair<int, int> info1, info2;
    bool lamp = false;
    for (int i = 0; i < n; ++i){
        //cerr << "checkver[" << i << "] == " << checkver[i] << endl;
        if (!checkver[i]){
            if (!lamp){
                info1 = find_gr_dim(i);
                lamp = true;
            }
            else info2 = find_gr_dim(i);
        }
    }
    int diam1 = info1.first + info1.second;
    int diam2 = info2.first + info2.second;
    int max1 = max(info1.first, info1.second);
    int max2 = max (info2.first, info2.second);
    anscost = max1 + max2 + lprice;
    anscost = max(anscost, diam1);
    anscost = max(anscost, diam2);
}

inline void solve(int *a, int *b, int *t){
    init_vectors(a, b, t);
    pair<int, int> info;
    multiset<int> comp;
    for (int i = 0; i < n; ++i){
        //cerr << "checkver[" << i << "] == " << checkver[i] << endl;
        if (!checkver[i]){
            info = find_gr_dim(i);
            int m1 = max(info.first, info.second);
            int m2 = min(info.first, info.second);
            comp.insert(m1);
            int sum = m1 + m2;
            anscost = max(anscost, sum);
        }
    }
    int m1, m2, m3;
    m1 = m2 = m3 = 0;
    auto it = comp.end();
    --it;
    m1 = *it;
    if (it == comp.begin())
        return;
    --it;
    m2 = *it;
    if (it == comp.begin()){
        int sum = m1 + m2 + lprice;
        anscost = max(anscost, sum);
        return;
    }
    --it;
    m3 = *it;
    int sum = m1 + m2 + lprice;
    anscost = max(anscost, sum);
    sum = m2 + m3 + lprice + lprice;
    anscost = max(anscost, sum);

}

int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    n = N;
    m = M;
    lprice = L;
    //subtask1(A, B, T);
    //subtask123(A, B, T);
    solve(A, B, T);
    return anscost;
}

    /*cout << n1 << " " << n2 << "\n";
    for (int i = 0; i < n1; ++i)
        cout << parsum1[i] << " ";
    cout << "\n";
    for (int i = 0; i < n2; ++i)
        cout << parsum2[i] << " ";
    cout << "\n";*/

/*int find_deepest(int ver){
    //cout << "ver " << ver << "\n";
    used[ver] = true;
    if (!used[v[ver][0].first])
        return find_deepest(v[ver][0].first);
    if (v[ver].size() > 1 && !used[v[ver][1].first])
        return find_deepest(v[ver][1].first);
    return ver;
}

inline void init_chain(int i, int &s, int &f){
    //cout << "i: " << i << "\n";
    used[i] = true;
    if (v[i].size() == 0) s = i;
    else s = find_deepest(v[i][0].first);
    //cerr << "found one end\n";
    if (v[i].size() <= 1) f = i;
    else f = find_deepest(v[i][1].first);
    //cerr << "found another end\n\n";
}

inline void find_chains(int &s1, int &f1, int &s2, int &f2){
    s1 = f1 = s2 = f2 = -1;
    for (int i = 0; i < n; ++i)
        if (!used[i]){
            if (s1 == -1) init_chain(i, s1, f1);
            else init_chain(i, s2, f2);
        }
}

int init_parsums(int s, int f, int *parsum){
    int cur = s, prev = -1;
    int cnt = 1;
    while (cur != f){
        for (pair<int, int> nb: v[cur])
            if (nb.first != prev){
                parsum[cnt] = parsum[cnt - 1] + nb.second;
                prev = cur;
                cur = nb.first;
                break;
            }
        cnt++;
    }
    return cnt;
}

pair<int, int> find_mindif(int n, int *parsum){
    if (n == 1) return {0, 0};
    if (n == 2) return {0, parsum[1]};
    int sum1 = -(1<<30) + 10, sum2 = (1<<30) - 10;
    for (int i = 0; i < n; ++i){
        int cursum1 = parsum[i];
        int cursum2 = parsum[n - 1] - parsum[i];
        if (abs(cursum2 - cursum1) < abs(sum2 - sum1)){
            sum1 = cursum1;
            sum2 = cursum2;
        }
    }
    return {sum1, sum2};
}

inline void subtask1(int *a, int *b, int *t){
    init_vectors(a, b, t);
    int s1, f1, s2, f2;
    find_chains(s1, f1, s2, f2);
    int n1 = init_parsums(s1, f1, parsum1);
    int n2 = init_parsums(s2, f2, parsum2);
    pair<int, int> sums1, sums2;
    sums1 = find_mindif(n1, parsum1);
    sums2 = find_mindif(n2, parsum2);
    //cout << sums1.first << " " << sums1.second << " " << sums2.first << " " << sums2.second << "\n";
    int max1 = max(sums1.first, sums1.second);
    int max2 = max(sums2.first, sums2.second);
    anscost = max1 + max2 + lprice;
    anscost = max(anscost, sums1.first + sums1.second);
    anscost = max(anscost, sums2.first + sums2.second);
}
*/

Compilation message

dreaming.cpp: In function 'int init_parsums(int, int, int*)':
dreaming.cpp:141:18: warning: unused variable 'prev' [-Wunused-variable]
  141 |     int cur = f, prev = -1;
      |                  ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 13556 KB Output is correct
2 Correct 62 ms 13776 KB Output is correct
3 Correct 32 ms 10756 KB Output is correct
4 Correct 8 ms 7096 KB Output is correct
5 Correct 7 ms 6748 KB Output is correct
6 Correct 12 ms 7608 KB Output is correct
7 Correct 3 ms 5980 KB Output is correct
8 Correct 23 ms 8916 KB Output is correct
9 Correct 29 ms 9880 KB Output is correct
10 Correct 2 ms 6236 KB Output is correct
11 Correct 41 ms 10452 KB Output is correct
12 Correct 49 ms 11996 KB Output is correct
13 Correct 2 ms 6236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5976 KB Output is correct
2 Correct 2 ms 5980 KB Output is correct
3 Correct 2 ms 5980 KB Output is correct
4 Correct 2 ms 5980 KB Output is correct
5 Correct 2 ms 6064 KB Output is correct
6 Correct 2 ms 5980 KB Output is correct
7 Correct 2 ms 5980 KB Output is correct
8 Correct 2 ms 5980 KB Output is correct
9 Correct 2 ms 5976 KB Output is correct
10 Correct 2 ms 5980 KB Output is correct
11 Correct 2 ms 5980 KB Output is correct
12 Correct 2 ms 5980 KB Output is correct
13 Correct 2 ms 5976 KB Output is correct
14 Correct 2 ms 5976 KB Output is correct
15 Correct 1 ms 3420 KB Output is correct
16 Correct 2 ms 5980 KB Output is correct
17 Correct 2 ms 5976 KB Output is correct
18 Correct 2 ms 5980 KB Output is correct
19 Correct 1 ms 5980 KB Output is correct
20 Correct 2 ms 5980 KB Output is correct
21 Correct 2 ms 5980 KB Output is correct
22 Correct 2 ms 5980 KB Output is correct
23 Correct 2 ms 5980 KB Output is correct
24 Correct 2 ms 5980 KB Output is correct
25 Correct 2 ms 5976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 13556 KB Output is correct
2 Correct 62 ms 13776 KB Output is correct
3 Correct 32 ms 10756 KB Output is correct
4 Correct 8 ms 7096 KB Output is correct
5 Correct 7 ms 6748 KB Output is correct
6 Correct 12 ms 7608 KB Output is correct
7 Correct 3 ms 5980 KB Output is correct
8 Correct 23 ms 8916 KB Output is correct
9 Correct 29 ms 9880 KB Output is correct
10 Correct 2 ms 6236 KB Output is correct
11 Correct 41 ms 10452 KB Output is correct
12 Correct 49 ms 11996 KB Output is correct
13 Correct 2 ms 6236 KB Output is correct
14 Correct 2 ms 5976 KB Output is correct
15 Correct 2 ms 5980 KB Output is correct
16 Correct 2 ms 5980 KB Output is correct
17 Correct 2 ms 5980 KB Output is correct
18 Correct 2 ms 6064 KB Output is correct
19 Correct 2 ms 5980 KB Output is correct
20 Correct 2 ms 5980 KB Output is correct
21 Correct 2 ms 5980 KB Output is correct
22 Correct 2 ms 5976 KB Output is correct
23 Correct 2 ms 5980 KB Output is correct
24 Correct 2 ms 5980 KB Output is correct
25 Correct 2 ms 5980 KB Output is correct
26 Correct 2 ms 5976 KB Output is correct
27 Correct 2 ms 5976 KB Output is correct
28 Correct 1 ms 3420 KB Output is correct
29 Correct 2 ms 5980 KB Output is correct
30 Correct 2 ms 5976 KB Output is correct
31 Correct 2 ms 5980 KB Output is correct
32 Correct 1 ms 5980 KB Output is correct
33 Correct 2 ms 5980 KB Output is correct
34 Correct 2 ms 5980 KB Output is correct
35 Correct 2 ms 5980 KB Output is correct
36 Correct 2 ms 5980 KB Output is correct
37 Correct 2 ms 5980 KB Output is correct
38 Correct 2 ms 5976 KB Output is correct
39 Correct 51 ms 13748 KB Output is correct
40 Correct 48 ms 13516 KB Output is correct
41 Correct 32 ms 10948 KB Output is correct
42 Correct 8 ms 7096 KB Output is correct
43 Correct 2 ms 5980 KB Output is correct
44 Correct 2 ms 5980 KB Output is correct
45 Correct 2 ms 5980 KB Output is correct
46 Correct 2 ms 5980 KB Output is correct
47 Correct 2 ms 5976 KB Output is correct
48 Correct 2 ms 5980 KB Output is correct
49 Correct 2 ms 5980 KB Output is correct
50 Correct 2 ms 5980 KB Output is correct
51 Correct 2 ms 5980 KB Output is correct
52 Correct 2 ms 5980 KB Output is correct
53 Correct 2 ms 5992 KB Output is correct
54 Correct 2 ms 5980 KB Output is correct
55 Correct 2 ms 5980 KB Output is correct
56 Correct 2 ms 5980 KB Output is correct
57 Correct 71 ms 14500 KB Output is correct
58 Correct 62 ms 13232 KB Output is correct
59 Correct 60 ms 14824 KB Output is correct
60 Correct 59 ms 12672 KB Output is correct
61 Correct 66 ms 14460 KB Output is correct
62 Correct 59 ms 13132 KB Output is correct
63 Correct 63 ms 15120 KB Output is correct
64 Correct 63 ms 14416 KB Output is correct
65 Correct 60 ms 14464 KB Output is correct
66 Correct 67 ms 14468 KB Output is correct
67 Correct 60 ms 14320 KB Output is correct
68 Correct 61 ms 14460 KB Output is correct
69 Correct 65 ms 13000 KB Output is correct
70 Correct 59 ms 12740 KB Output is correct
71 Correct 1 ms 3672 KB Output is correct
72 Correct 3 ms 6236 KB Output is correct
73 Correct 3 ms 6232 KB Output is correct
74 Correct 3 ms 6236 KB Output is correct
75 Correct 3 ms 6176 KB Output is correct
76 Correct 3 ms 6236 KB Output is correct
77 Correct 3 ms 6236 KB Output is correct
78 Correct 3 ms 6236 KB Output is correct
79 Correct 3 ms 6236 KB Output is correct
80 Correct 62 ms 13356 KB Output is correct
81 Correct 71 ms 13252 KB Output is correct
82 Correct 63 ms 14576 KB Output is correct
83 Correct 67 ms 14972 KB Output is correct
84 Correct 3 ms 6488 KB Output is correct
85 Correct 3 ms 6236 KB Output is correct
86 Correct 3 ms 6236 KB Output is correct
87 Correct 3 ms 6236 KB Output is correct
88 Correct 3 ms 6232 KB Output is correct
89 Correct 3 ms 6236 KB Output is correct
90 Correct 3 ms 6236 KB Output is correct
91 Correct 3 ms 6348 KB Output is correct
92 Correct 3 ms 6236 KB Output is correct
93 Correct 3 ms 6232 KB Output is correct
94 Correct 2 ms 6232 KB Output is correct
95 Correct 2 ms 5980 KB Output is correct
96 Correct 2 ms 5980 KB Output is correct
97 Correct 2 ms 5980 KB Output is correct
98 Correct 2 ms 5980 KB Output is correct
99 Correct 2 ms 5980 KB Output is correct
100 Correct 2 ms 5980 KB Output is correct
101 Correct 2 ms 6232 KB Output is correct
102 Correct 2 ms 5980 KB Output is correct
103 Correct 2 ms 6184 KB Output is correct
104 Correct 10 ms 6748 KB Output is correct
105 Correct 11 ms 7620 KB Output is correct
106 Correct 2 ms 5980 KB Output is correct
107 Correct 25 ms 9040 KB Output is correct
108 Correct 29 ms 9816 KB Output is correct
109 Correct 2 ms 6236 KB Output is correct
110 Correct 45 ms 10448 KB Output is correct
111 Correct 59 ms 11972 KB Output is correct
112 Correct 2 ms 6232 KB Output is correct
113 Correct 81 ms 14460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 267 ms 11400 KB Output is correct
2 Correct 250 ms 11404 KB Output is correct
3 Correct 268 ms 11600 KB Output is correct
4 Correct 231 ms 11348 KB Output is correct
5 Correct 266 ms 11500 KB Output is correct
6 Correct 286 ms 11996 KB Output is correct
7 Correct 278 ms 11604 KB Output is correct
8 Correct 257 ms 11288 KB Output is correct
9 Correct 263 ms 11452 KB Output is correct
10 Correct 256 ms 11716 KB Output is correct
11 Correct 2 ms 5980 KB Output is correct
12 Correct 16 ms 11096 KB Output is correct
13 Correct 19 ms 11100 KB Output is correct
14 Correct 16 ms 11256 KB Output is correct
15 Correct 17 ms 11248 KB Output is correct
16 Correct 20 ms 11032 KB Output is correct
17 Correct 16 ms 11072 KB Output is correct
18 Correct 20 ms 11100 KB Output is correct
19 Correct 16 ms 11100 KB Output is correct
20 Correct 1 ms 3420 KB Output is correct
21 Correct 1 ms 3420 KB Output is correct
22 Correct 2 ms 6232 KB Output is correct
23 Correct 19 ms 11276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5976 KB Output is correct
2 Correct 2 ms 5980 KB Output is correct
3 Correct 2 ms 5980 KB Output is correct
4 Correct 2 ms 5980 KB Output is correct
5 Correct 2 ms 6064 KB Output is correct
6 Correct 2 ms 5980 KB Output is correct
7 Correct 2 ms 5980 KB Output is correct
8 Correct 2 ms 5980 KB Output is correct
9 Correct 2 ms 5976 KB Output is correct
10 Correct 2 ms 5980 KB Output is correct
11 Correct 2 ms 5980 KB Output is correct
12 Correct 2 ms 5980 KB Output is correct
13 Correct 2 ms 5976 KB Output is correct
14 Correct 2 ms 5976 KB Output is correct
15 Correct 1 ms 3420 KB Output is correct
16 Correct 2 ms 5980 KB Output is correct
17 Correct 2 ms 5976 KB Output is correct
18 Correct 2 ms 5980 KB Output is correct
19 Correct 1 ms 5980 KB Output is correct
20 Correct 2 ms 5980 KB Output is correct
21 Correct 2 ms 5980 KB Output is correct
22 Correct 2 ms 5980 KB Output is correct
23 Correct 2 ms 5980 KB Output is correct
24 Correct 2 ms 5980 KB Output is correct
25 Correct 2 ms 5976 KB Output is correct
26 Correct 4 ms 6236 KB Output is correct
27 Correct 4 ms 6236 KB Output is correct
28 Correct 7 ms 6236 KB Output is correct
29 Correct 3 ms 6236 KB Output is correct
30 Correct 4 ms 6232 KB Output is correct
31 Correct 6 ms 6236 KB Output is correct
32 Correct 3 ms 6236 KB Output is correct
33 Correct 4 ms 6236 KB Output is correct
34 Correct 5 ms 6352 KB Output is correct
35 Correct 2 ms 5980 KB Output is correct
36 Correct 1 ms 5980 KB Output is correct
37 Correct 2 ms 5976 KB Output is correct
38 Correct 2 ms 5980 KB Output is correct
39 Correct 2 ms 6156 KB Output is correct
40 Correct 2 ms 6232 KB Output is correct
41 Correct 2 ms 5980 KB Output is correct
42 Correct 2 ms 5976 KB Output is correct
43 Correct 2 ms 5980 KB Output is correct
44 Correct 2 ms 5976 KB Output is correct
45 Correct 3 ms 5980 KB Output is correct
46 Correct 2 ms 5980 KB Output is correct
47 Correct 2 ms 5980 KB Output is correct
48 Correct 2 ms 5980 KB Output is correct
49 Correct 2 ms 5980 KB Output is correct
50 Correct 2 ms 5980 KB Output is correct
51 Correct 2 ms 5980 KB Output is correct
52 Correct 1 ms 3416 KB Output is correct
53 Correct 1 ms 3416 KB Output is correct
54 Correct 3 ms 6236 KB Output is correct
55 Correct 3 ms 6236 KB Output is correct
56 Correct 8 ms 6308 KB Output is correct
57 Correct 6 ms 6284 KB Output is correct
58 Correct 3 ms 6236 KB Output is correct
59 Correct 3 ms 6236 KB Output is correct
60 Correct 11 ms 6236 KB Output is correct
61 Correct 6 ms 6232 KB Output is correct
62 Correct 3 ms 6236 KB Output is correct
63 Correct 3 ms 6236 KB Output is correct
64 Correct 4 ms 6232 KB Output is correct
65 Correct 8 ms 6236 KB Output is correct
66 Correct 3 ms 6236 KB Output is correct
67 Correct 3 ms 6236 KB Output is correct
68 Correct 10 ms 6492 KB Output is correct
69 Correct 7 ms 6236 KB Output is correct
70 Correct 7 ms 6232 KB Output is correct
71 Correct 7 ms 6232 KB Output is correct
72 Correct 5 ms 6464 KB Output is correct
73 Correct 4 ms 6236 KB Output is correct
74 Correct 4 ms 6236 KB Output is correct
75 Correct 4 ms 6240 KB Output is correct
76 Correct 3 ms 6408 KB Output is correct
77 Correct 3 ms 6240 KB Output is correct
78 Correct 7 ms 6236 KB Output is correct
79 Correct 7 ms 6240 KB Output is correct
80 Correct 3 ms 6240 KB Output is correct
81 Correct 3 ms 6388 KB Output is correct
82 Correct 5 ms 6236 KB Output is correct
83 Correct 5 ms 6236 KB Output is correct
84 Correct 4 ms 6236 KB Output is correct
85 Correct 3 ms 6236 KB Output is correct
86 Correct 5 ms 6236 KB Output is correct
87 Correct 4 ms 6464 KB Output is correct
88 Correct 7 ms 6232 KB Output is correct
89 Correct 8 ms 6192 KB Output is correct
90 Correct 8 ms 6488 KB Output is correct
91 Correct 7 ms 6236 KB Output is correct
92 Correct 3 ms 6232 KB Output is correct
93 Correct 2 ms 6324 KB Output is correct
94 Correct 3 ms 6232 KB Output is correct
95 Correct 3 ms 6236 KB Output is correct
96 Correct 3 ms 6236 KB Output is correct
97 Correct 3 ms 6236 KB Output is correct
98 Correct 3 ms 6236 KB Output is correct
99 Correct 3 ms 6236 KB Output is correct
100 Correct 3 ms 6236 KB Output is correct
101 Correct 3 ms 6236 KB Output is correct
102 Correct 2 ms 5980 KB Output is correct
103 Correct 2 ms 5980 KB Output is correct
104 Correct 2 ms 5980 KB Output is correct
105 Correct 2 ms 5976 KB Output is correct
106 Correct 2 ms 5980 KB Output is correct
107 Correct 2 ms 5980 KB Output is correct
108 Correct 2 ms 5976 KB Output is correct
109 Correct 2 ms 5976 KB Output is correct
110 Correct 2 ms 6232 KB Output is correct
111 Correct 2 ms 5980 KB Output is correct
112 Correct 2 ms 5980 KB Output is correct
113 Correct 2 ms 6236 KB Output is correct
114 Correct 2 ms 6236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 13556 KB Output is correct
2 Correct 62 ms 13776 KB Output is correct
3 Correct 32 ms 10756 KB Output is correct
4 Correct 8 ms 7096 KB Output is correct
5 Correct 7 ms 6748 KB Output is correct
6 Correct 12 ms 7608 KB Output is correct
7 Correct 3 ms 5980 KB Output is correct
8 Correct 23 ms 8916 KB Output is correct
9 Correct 29 ms 9880 KB Output is correct
10 Correct 2 ms 6236 KB Output is correct
11 Correct 41 ms 10452 KB Output is correct
12 Correct 49 ms 11996 KB Output is correct
13 Correct 2 ms 6236 KB Output is correct
14 Correct 2 ms 5976 KB Output is correct
15 Correct 2 ms 5980 KB Output is correct
16 Correct 2 ms 5980 KB Output is correct
17 Correct 2 ms 5980 KB Output is correct
18 Correct 2 ms 6064 KB Output is correct
19 Correct 2 ms 5980 KB Output is correct
20 Correct 2 ms 5980 KB Output is correct
21 Correct 2 ms 5980 KB Output is correct
22 Correct 2 ms 5976 KB Output is correct
23 Correct 2 ms 5980 KB Output is correct
24 Correct 2 ms 5980 KB Output is correct
25 Correct 2 ms 5980 KB Output is correct
26 Correct 2 ms 5976 KB Output is correct
27 Correct 2 ms 5976 KB Output is correct
28 Correct 1 ms 3420 KB Output is correct
29 Correct 2 ms 5980 KB Output is correct
30 Correct 2 ms 5976 KB Output is correct
31 Correct 2 ms 5980 KB Output is correct
32 Correct 1 ms 5980 KB Output is correct
33 Correct 2 ms 5980 KB Output is correct
34 Correct 2 ms 5980 KB Output is correct
35 Correct 2 ms 5980 KB Output is correct
36 Correct 2 ms 5980 KB Output is correct
37 Correct 2 ms 5980 KB Output is correct
38 Correct 2 ms 5976 KB Output is correct
39 Correct 51 ms 13748 KB Output is correct
40 Correct 48 ms 13516 KB Output is correct
41 Correct 32 ms 10948 KB Output is correct
42 Correct 8 ms 7096 KB Output is correct
43 Correct 2 ms 5980 KB Output is correct
44 Correct 2 ms 5980 KB Output is correct
45 Correct 2 ms 5980 KB Output is correct
46 Correct 2 ms 5980 KB Output is correct
47 Correct 2 ms 5976 KB Output is correct
48 Correct 2 ms 5980 KB Output is correct
49 Correct 2 ms 5980 KB Output is correct
50 Correct 2 ms 5980 KB Output is correct
51 Correct 2 ms 5980 KB Output is correct
52 Correct 2 ms 5980 KB Output is correct
53 Correct 2 ms 5992 KB Output is correct
54 Correct 2 ms 5980 KB Output is correct
55 Correct 2 ms 5980 KB Output is correct
56 Correct 2 ms 5980 KB Output is correct
57 Correct 71 ms 14500 KB Output is correct
58 Correct 62 ms 13232 KB Output is correct
59 Correct 60 ms 14824 KB Output is correct
60 Correct 59 ms 12672 KB Output is correct
61 Correct 66 ms 14460 KB Output is correct
62 Correct 59 ms 13132 KB Output is correct
63 Correct 63 ms 15120 KB Output is correct
64 Correct 63 ms 14416 KB Output is correct
65 Correct 60 ms 14464 KB Output is correct
66 Correct 67 ms 14468 KB Output is correct
67 Correct 60 ms 14320 KB Output is correct
68 Correct 61 ms 14460 KB Output is correct
69 Correct 65 ms 13000 KB Output is correct
70 Correct 59 ms 12740 KB Output is correct
71 Correct 1 ms 3672 KB Output is correct
72 Correct 3 ms 6236 KB Output is correct
73 Correct 3 ms 6232 KB Output is correct
74 Correct 3 ms 6236 KB Output is correct
75 Correct 3 ms 6176 KB Output is correct
76 Correct 3 ms 6236 KB Output is correct
77 Correct 3 ms 6236 KB Output is correct
78 Correct 3 ms 6236 KB Output is correct
79 Correct 3 ms 6236 KB Output is correct
80 Correct 62 ms 13356 KB Output is correct
81 Correct 71 ms 13252 KB Output is correct
82 Correct 63 ms 14576 KB Output is correct
83 Correct 67 ms 14972 KB Output is correct
84 Correct 3 ms 6488 KB Output is correct
85 Correct 3 ms 6236 KB Output is correct
86 Correct 3 ms 6236 KB Output is correct
87 Correct 3 ms 6236 KB Output is correct
88 Correct 3 ms 6232 KB Output is correct
89 Correct 3 ms 6236 KB Output is correct
90 Correct 3 ms 6236 KB Output is correct
91 Correct 3 ms 6348 KB Output is correct
92 Correct 3 ms 6236 KB Output is correct
93 Correct 3 ms 6232 KB Output is correct
94 Correct 2 ms 6232 KB Output is correct
95 Correct 2 ms 5980 KB Output is correct
96 Correct 2 ms 5980 KB Output is correct
97 Correct 2 ms 5980 KB Output is correct
98 Correct 2 ms 5980 KB Output is correct
99 Correct 2 ms 5980 KB Output is correct
100 Correct 2 ms 5980 KB Output is correct
101 Correct 2 ms 6232 KB Output is correct
102 Correct 2 ms 5980 KB Output is correct
103 Correct 2 ms 6184 KB Output is correct
104 Correct 10 ms 6748 KB Output is correct
105 Correct 11 ms 7620 KB Output is correct
106 Correct 2 ms 5980 KB Output is correct
107 Correct 25 ms 9040 KB Output is correct
108 Correct 29 ms 9816 KB Output is correct
109 Correct 2 ms 6236 KB Output is correct
110 Correct 45 ms 10448 KB Output is correct
111 Correct 59 ms 11972 KB Output is correct
112 Correct 2 ms 6232 KB Output is correct
113 Correct 81 ms 14460 KB Output is correct
114 Correct 267 ms 11400 KB Output is correct
115 Correct 250 ms 11404 KB Output is correct
116 Correct 268 ms 11600 KB Output is correct
117 Correct 231 ms 11348 KB Output is correct
118 Correct 266 ms 11500 KB Output is correct
119 Correct 286 ms 11996 KB Output is correct
120 Correct 278 ms 11604 KB Output is correct
121 Correct 257 ms 11288 KB Output is correct
122 Correct 263 ms 11452 KB Output is correct
123 Correct 256 ms 11716 KB Output is correct
124 Correct 2 ms 5980 KB Output is correct
125 Correct 16 ms 11096 KB Output is correct
126 Correct 19 ms 11100 KB Output is correct
127 Correct 16 ms 11256 KB Output is correct
128 Correct 17 ms 11248 KB Output is correct
129 Correct 20 ms 11032 KB Output is correct
130 Correct 16 ms 11072 KB Output is correct
131 Correct 20 ms 11100 KB Output is correct
132 Correct 16 ms 11100 KB Output is correct
133 Correct 1 ms 3420 KB Output is correct
134 Correct 1 ms 3420 KB Output is correct
135 Correct 2 ms 6232 KB Output is correct
136 Correct 19 ms 11276 KB Output is correct
137 Correct 4 ms 6236 KB Output is correct
138 Correct 4 ms 6236 KB Output is correct
139 Correct 7 ms 6236 KB Output is correct
140 Correct 3 ms 6236 KB Output is correct
141 Correct 4 ms 6232 KB Output is correct
142 Correct 6 ms 6236 KB Output is correct
143 Correct 3 ms 6236 KB Output is correct
144 Correct 4 ms 6236 KB Output is correct
145 Correct 5 ms 6352 KB Output is correct
146 Correct 2 ms 5980 KB Output is correct
147 Correct 1 ms 5980 KB Output is correct
148 Correct 2 ms 5976 KB Output is correct
149 Correct 2 ms 5980 KB Output is correct
150 Correct 2 ms 6156 KB Output is correct
151 Correct 2 ms 6232 KB Output is correct
152 Correct 2 ms 5980 KB Output is correct
153 Correct 2 ms 5976 KB Output is correct
154 Correct 2 ms 5980 KB Output is correct
155 Correct 2 ms 5976 KB Output is correct
156 Correct 3 ms 5980 KB Output is correct
157 Correct 2 ms 5980 KB Output is correct
158 Correct 2 ms 5980 KB Output is correct
159 Correct 2 ms 5980 KB Output is correct
160 Correct 2 ms 5980 KB Output is correct
161 Correct 2 ms 5980 KB Output is correct
162 Correct 2 ms 5980 KB Output is correct
163 Correct 1 ms 3416 KB Output is correct
164 Correct 1 ms 3416 KB Output is correct
165 Correct 3 ms 6236 KB Output is correct
166 Correct 3 ms 6236 KB Output is correct
167 Correct 8 ms 6308 KB Output is correct
168 Correct 6 ms 6284 KB Output is correct
169 Correct 3 ms 6236 KB Output is correct
170 Correct 3 ms 6236 KB Output is correct
171 Correct 11 ms 6236 KB Output is correct
172 Correct 6 ms 6232 KB Output is correct
173 Correct 3 ms 6236 KB Output is correct
174 Correct 3 ms 6236 KB Output is correct
175 Correct 4 ms 6232 KB Output is correct
176 Correct 8 ms 6236 KB Output is correct
177 Correct 3 ms 6236 KB Output is correct
178 Correct 3 ms 6236 KB Output is correct
179 Correct 10 ms 6492 KB Output is correct
180 Correct 7 ms 6236 KB Output is correct
181 Correct 7 ms 6232 KB Output is correct
182 Correct 7 ms 6232 KB Output is correct
183 Correct 5 ms 6464 KB Output is correct
184 Correct 4 ms 6236 KB Output is correct
185 Correct 4 ms 6236 KB Output is correct
186 Correct 4 ms 6240 KB Output is correct
187 Correct 3 ms 6408 KB Output is correct
188 Correct 3 ms 6240 KB Output is correct
189 Correct 7 ms 6236 KB Output is correct
190 Correct 7 ms 6240 KB Output is correct
191 Correct 3 ms 6240 KB Output is correct
192 Correct 3 ms 6388 KB Output is correct
193 Correct 5 ms 6236 KB Output is correct
194 Correct 5 ms 6236 KB Output is correct
195 Correct 4 ms 6236 KB Output is correct
196 Correct 3 ms 6236 KB Output is correct
197 Correct 5 ms 6236 KB Output is correct
198 Correct 4 ms 6464 KB Output is correct
199 Correct 7 ms 6232 KB Output is correct
200 Correct 8 ms 6192 KB Output is correct
201 Correct 8 ms 6488 KB Output is correct
202 Correct 7 ms 6236 KB Output is correct
203 Correct 3 ms 6232 KB Output is correct
204 Correct 2 ms 6324 KB Output is correct
205 Correct 3 ms 6232 KB Output is correct
206 Correct 3 ms 6236 KB Output is correct
207 Correct 3 ms 6236 KB Output is correct
208 Correct 3 ms 6236 KB Output is correct
209 Correct 3 ms 6236 KB Output is correct
210 Correct 3 ms 6236 KB Output is correct
211 Correct 3 ms 6236 KB Output is correct
212 Correct 3 ms 6236 KB Output is correct
213 Correct 2 ms 5980 KB Output is correct
214 Correct 2 ms 5980 KB Output is correct
215 Correct 2 ms 5980 KB Output is correct
216 Correct 2 ms 5976 KB Output is correct
217 Correct 2 ms 5980 KB Output is correct
218 Correct 2 ms 5980 KB Output is correct
219 Correct 2 ms 5976 KB Output is correct
220 Correct 2 ms 5976 KB Output is correct
221 Correct 2 ms 6232 KB Output is correct
222 Correct 2 ms 5980 KB Output is correct
223 Correct 2 ms 5980 KB Output is correct
224 Correct 2 ms 6236 KB Output is correct
225 Correct 2 ms 6236 KB Output is correct
226 Correct 3 ms 6236 KB Output is correct
227 Correct 4 ms 6236 KB Output is correct
228 Correct 6 ms 6344 KB Output is correct
229 Correct 122 ms 10468 KB Output is correct
230 Correct 144 ms 11304 KB Output is correct
231 Correct 3 ms 6232 KB Output is correct
232 Correct 4 ms 6236 KB Output is correct
233 Correct 5 ms 6196 KB Output is correct
234 Correct 117 ms 10132 KB Output is correct
235 Correct 163 ms 11600 KB Output is correct
236 Correct 3 ms 6236 KB Output is correct
237 Correct 4 ms 6232 KB Output is correct
238 Correct 5 ms 6252 KB Output is correct
239 Correct 102 ms 10252 KB Output is correct
240 Correct 130 ms 11344 KB Output is correct
241 Correct 265 ms 11600 KB Output is correct
242 Correct 256 ms 11624 KB Output is correct
243 Correct 260 ms 11312 KB Output is correct
244 Correct 242 ms 11624 KB Output is correct
245 Correct 248 ms 11708 KB Output is correct
246 Correct 287 ms 11856 KB Output is correct
247 Correct 281 ms 12184 KB Output is correct
248 Correct 258 ms 11836 KB Output is correct
249 Correct 264 ms 11520 KB Output is correct
250 Correct 268 ms 11816 KB Output is correct
251 Correct 2 ms 6176 KB Output is correct
252 Correct 67 ms 14032 KB Output is correct
253 Correct 55 ms 14204 KB Output is correct
254 Correct 32 ms 11344 KB Output is correct
255 Correct 9 ms 7304 KB Output is correct
256 Correct 2 ms 5980 KB Output is correct
257 Correct 2 ms 5980 KB Output is correct
258 Correct 2 ms 5980 KB Output is correct
259 Correct 2 ms 5980 KB Output is correct
260 Correct 2 ms 5980 KB Output is correct
261 Correct 2 ms 6180 KB Output is correct
262 Correct 2 ms 5976 KB Output is correct
263 Correct 2 ms 5980 KB Output is correct
264 Correct 2 ms 5980 KB Output is correct
265 Correct 2 ms 5980 KB Output is correct
266 Correct 2 ms 6232 KB Output is correct
267 Correct 2 ms 5980 KB Output is correct
268 Correct 2 ms 6184 KB Output is correct
269 Correct 2 ms 5980 KB Output is correct
270 Correct 2 ms 5980 KB Output is correct
271 Correct 2 ms 6232 KB Output is correct
272 Correct 68 ms 14864 KB Output is correct
273 Correct 71 ms 13788 KB Output is correct
274 Correct 66 ms 15520 KB Output is correct
275 Correct 72 ms 13296 KB Output is correct
276 Correct 17 ms 11100 KB Output is correct
277 Correct 20 ms 11092 KB Output is correct
278 Correct 93 ms 15260 KB Output is correct
279 Correct 104 ms 13820 KB Output is correct
280 Correct 66 ms 15660 KB Output is correct
281 Correct 65 ms 15228 KB Output is correct
282 Correct 65 ms 15296 KB Output is correct
283 Correct 58 ms 15276 KB Output is correct
284 Correct 65 ms 14948 KB Output is correct
285 Correct 69 ms 14992 KB Output is correct
286 Correct 71 ms 13612 KB Output is correct
287 Correct 60 ms 13648 KB Output is correct
288 Correct 17 ms 11280 KB Output is correct
289 Correct 17 ms 11100 KB Output is correct
290 Correct 19 ms 11100 KB Output is correct
291 Correct 15 ms 11100 KB Output is correct
292 Correct 20 ms 11148 KB Output is correct
293 Correct 18 ms 11048 KB Output is correct
294 Correct 1 ms 3620 KB Output is correct
295 Correct 2 ms 3624 KB Output is correct
296 Correct 3 ms 6236 KB Output is correct
297 Correct 3 ms 6236 KB Output is correct
298 Correct 57 ms 15128 KB Output is correct
299 Correct 68 ms 14888 KB Output is correct
300 Correct 7 ms 6236 KB Output is correct
301 Correct 6 ms 6236 KB Output is correct
302 Correct 3 ms 6200 KB Output is correct
303 Correct 4 ms 6480 KB Output is correct
304 Correct 7 ms 6236 KB Output is correct
305 Correct 7 ms 6236 KB Output is correct
306 Correct 3 ms 6236 KB Output is correct
307 Correct 4 ms 6220 KB Output is correct
308 Correct 4 ms 6236 KB Output is correct
309 Correct 11 ms 6320 KB Output is correct
310 Correct 3 ms 6236 KB Output is correct
311 Correct 5 ms 6232 KB Output is correct
312 Correct 8 ms 6236 KB Output is correct
313 Correct 10 ms 6236 KB Output is correct
314 Correct 7 ms 6236 KB Output is correct
315 Correct 8 ms 6320 KB Output is correct
316 Correct 3 ms 6452 KB Output is correct
317 Correct 4 ms 6448 KB Output is correct
318 Correct 5 ms 6236 KB Output is correct
319 Correct 6 ms 6236 KB Output is correct
320 Correct 5 ms 6424 KB Output is correct
321 Correct 3 ms 6236 KB Output is correct
322 Correct 7 ms 6236 KB Output is correct
323 Correct 10 ms 6232 KB Output is correct
324 Correct 3 ms 6236 KB Output is correct
325 Correct 2 ms 6236 KB Output is correct
326 Correct 8 ms 6236 KB Output is correct
327 Correct 5 ms 6236 KB Output is correct
328 Correct 4 ms 6236 KB Output is correct
329 Correct 3 ms 6236 KB Output is correct
330 Correct 4 ms 6204 KB Output is correct
331 Correct 4 ms 6232 KB Output is correct
332 Correct 11 ms 6372 KB Output is correct
333 Correct 8 ms 6236 KB Output is correct
334 Correct 8 ms 6236 KB Output is correct
335 Correct 8 ms 6236 KB Output is correct
336 Correct 70 ms 14168 KB Output is correct
337 Correct 97 ms 15384 KB Output is correct
338 Correct 71 ms 15896 KB Output is correct
339 Correct 66 ms 15208 KB Output is correct
340 Correct 170 ms 11596 KB Output is correct
341 Correct 202 ms 11864 KB Output is correct
342 Correct 63 ms 13876 KB Output is correct
343 Correct 86 ms 13692 KB Output is correct
344 Correct 228 ms 11568 KB Output is correct
345 Correct 204 ms 11608 KB Output is correct
346 Correct 73 ms 13276 KB Output is correct
347 Correct 72 ms 14200 KB Output is correct
348 Correct 133 ms 11352 KB Output is correct
349 Correct 158 ms 11776 KB Output is correct
350 Correct 64 ms 15504 KB Output is correct
351 Correct 80 ms 15576 KB Output is correct
352 Correct 38 ms 11348 KB Output is correct
353 Correct 168 ms 11672 KB Output is correct
354 Correct 225 ms 11736 KB Output is correct
355 Correct 194 ms 11812 KB Output is correct
356 Correct 233 ms 11404 KB Output is correct
357 Correct 101 ms 11344 KB Output is correct
358 Correct 219 ms 11808 KB Output is correct
359 Correct 210 ms 11952 KB Output is correct
360 Correct 21 ms 11200 KB Output is correct
361 Correct 16 ms 11232 KB Output is correct
362 Correct 100 ms 11392 KB Output is correct
363 Correct 66 ms 11232 KB Output is correct
364 Correct 103 ms 11020 KB Output is correct
365 Correct 83 ms 10532 KB Output is correct
366 Correct 86 ms 11044 KB Output is correct
367 Correct 94 ms 11924 KB Output is correct
368 Correct 208 ms 10724 KB Output is correct
369 Correct 224 ms 11492 KB Output is correct
370 Correct 230 ms 10832 KB Output is correct
371 Correct 209 ms 10784 KB Output is correct
372 Correct 3 ms 4404 KB Output is correct
373 Correct 3 ms 4188 KB Output is correct
374 Correct 3 ms 4188 KB Output is correct
375 Correct 3 ms 4184 KB Output is correct
376 Correct 3 ms 4184 KB Output is correct
377 Correct 3 ms 4184 KB Output is correct
378 Correct 3 ms 4408 KB Output is correct
379 Correct 3 ms 4404 KB Output is correct
380 Correct 3 ms 4408 KB Output is correct
381 Correct 3 ms 6236 KB Output is correct
382 Correct 1 ms 4188 KB Output is correct
383 Correct 2 ms 3928 KB Output is correct
384 Correct 2 ms 3932 KB Output is correct
385 Correct 2 ms 5976 KB Output is correct
386 Correct 2 ms 4188 KB Output is correct
387 Correct 2 ms 4188 KB Output is correct
388 Correct 2 ms 3932 KB Output is correct
389 Correct 2 ms 3932 KB Output is correct
390 Correct 2 ms 3928 KB Output is correct
391 Correct 3 ms 3932 KB Output is correct
392 Correct 6 ms 4956 KB Output is correct
393 Correct 12 ms 7864 KB Output is correct
394 Correct 3 ms 4188 KB Output is correct
395 Correct 40 ms 9168 KB Output is correct
396 Correct 32 ms 9040 KB Output is correct
397 Correct 2 ms 4184 KB Output is correct
398 Correct 71 ms 10180 KB Output is correct
399 Correct 51 ms 12424 KB Output is correct
400 Correct 2 ms 4188 KB Output is correct
401 Correct 127 ms 14544 KB Output is correct