Submission #17137939


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
void read (int &x) {
    char ch = getchar(); x = 0;
    while (!isdigit(ch)) ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
}
int l, n = 20, m, u[66], v[66], d[66], id[66];
void add (int a, int b, int len) {
    u[++m] = a, v[m] = b, d[m] = len;
}
signed main() {
    read (l);
    for (int i = 0, len = 1; i < 13; ++i) {
        id[i] = n - i - 1;
        add (id[i], id[i] + 1, 0);
        add (id[i], id[i] + 1, len);
        if (len * 3 <= 1000000) add (id[i], id[i] + 1, len * 2);
        len *= 3;
    }
    int now = 1, len = 0;
    for (int i = 1; i <= 12; ++i) now *= 3;
    for (int i = 12; i >= 0; --i, now /= 3)
        if (l >= now) {
            int tmp = l / now, to = i ? id[i - 1] : n;
            for (int j = 0; j < tmp; ++j)
                add (1, to, now * j + len);
            len += now * tmp; l %= now;
        }
    printf ("%d %d\n", n, m);
    for (int i = 1; i <= m; ++i)
        printf ("%d %d %d\n", u[i], v[i], d[i]);
    return 0;
}

Submission Info

Submission Time
Task D - All Your Paths are Different Lengths
User OIer_whx
Language C++ (GCC 9.2.1)
Score 700
Code Size 1079 Byte
Status AC
Exec Time 9 ms
Memory 3744 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 2
AC × 22
Set Name Test Cases
Sample s1.txt, s2.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt AC 8 ms 3560 KiB
02.txt AC 9 ms 3660 KiB
03.txt AC 3 ms 3656 KiB
04.txt AC 6 ms 3592 KiB
05.txt AC 3 ms 3616 KiB
06.txt AC 4 ms 3596 KiB
07.txt AC 3 ms 3648 KiB
08.txt AC 2 ms 3652 KiB
09.txt AC 2 ms 3696 KiB
10.txt AC 2 ms 3596 KiB
11.txt AC 2 ms 3592 KiB
12.txt AC 2 ms 3580 KiB
13.txt AC 2 ms 3744 KiB
14.txt AC 7 ms 3652 KiB
15.txt AC 7 ms 3456 KiB
16.txt AC 2 ms 3696 KiB
17.txt AC 9 ms 3652 KiB
18.txt AC 6 ms 3660 KiB
19.txt AC 2 ms 3596 KiB
20.txt AC 2 ms 3652 KiB
s1.txt AC 6 ms 3732 KiB
s2.txt AC 1 ms 3644 KiB