Submission #56966

# Submission time Handle Problem Language Result Execution time Memory
56966 2018-07-13T11:14:30 Z 조민규(#2115) JOIRIS (JOI16_joiris) C++11
100 / 100
4 ms 1296 KB
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <iterator>

using namespace std;

int arr[60];
int cur[60];
int tmp[60];
int cnt[60];

int main()
{
    //freopen("in", "r", stdin);
    //freopen("out", "w", stdout);

    int n, l, i, j, k;
    scanf("%d%d", &n, &l);
    for(i = 1; i <= n; i++)
        scanf("%d", &arr[i]);

    for(i = 0; i < l; i++)
    {
        for(j = 1; j <= n; j++)
        {
            cur[j] = arr[j];
            tmp[j] = (arr[j] + i) % l;
        }

        for(j = 1; j <= n - l + 1; j++)
        {
            cnt[j] = (l - tmp[j]) % l;
            for(k = j; k < j + l; k++)
                tmp[k] = (tmp[k] + cnt[j]) % l;
        }

        bool ok = 1;
        for(j = 1; j <= n; j++)
        {
            if(tmp[j])
            {
                ok = 0;
                break;
            }
        }
        if(!ok)
            continue;

        vector<pair<int, int>> res;
        for(j = 1; j <= n - l + 1; j++)
        {
            for(k = 0; k < cnt[j]; k++)
                res.push_back({ 2, j });

            int mx = 0;
            for(k = j; k < j + l; k++)
                mx = max(mx, cur[k]);

            int mn = 1e9;
            for(k = 1; k <= n; k++)
            {
                if(j <= k && k < j + l)
                    cur[k] += cnt[j];
                else
                {
                    while(cur[k] < mx + cnt[j])
                    {
                        res.push_back({ 1, k });
                        cur[k] += l;
                    }
                }

                mn = min(mn, cur[k]);
            }

            for(k = 1; k <= n; k++)
                cur[k] -= mn;
        }

        int mx = 0;
        for(j = 1; j <= n; j++)
            mx = max(mx, cur[j]);

        for(j = 1; j <= n; j++)
        {
            while(cur[j] < mx)
            {
                res.push_back({ 1, j });
                cur[j] += l;
            }
        }

        printf("%d\n", (int)res.size());
        for(auto &p : res)
            printf("%d %d\n", p.first, p.second);
        return 0;
    }

    printf("-1\n");
    return 0;
}

Compilation message

joiris.cpp: In function 'int main()':
joiris.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &l);
     ~~~~~^~~~~~~~~~~~~~~~
joiris.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &arr[i]);
         ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 556 KB Output is correct
7 Correct 3 ms 612 KB Output is correct
8 Correct 3 ms 612 KB Output is correct
9 Correct 2 ms 668 KB Output is correct
10 Correct 3 ms 668 KB Output is correct
11 Correct 2 ms 708 KB Output is correct
12 Correct 3 ms 708 KB Output is correct
13 Correct 3 ms 716 KB Output is correct
14 Correct 2 ms 716 KB Output is correct
15 Correct 2 ms 716 KB Output is correct
16 Correct 3 ms 728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 728 KB Output is correct
2 Correct 3 ms 764 KB Output is correct
3 Correct 3 ms 764 KB Output is correct
4 Correct 2 ms 764 KB Output is correct
5 Correct 2 ms 776 KB Output is correct
6 Correct 3 ms 796 KB Output is correct
7 Correct 3 ms 796 KB Output is correct
8 Correct 2 ms 796 KB Output is correct
9 Correct 2 ms 824 KB Output is correct
10 Correct 2 ms 828 KB Output is correct
11 Correct 3 ms 832 KB Output is correct
12 Correct 3 ms 836 KB Output is correct
13 Correct 2 ms 836 KB Output is correct
14 Correct 3 ms 836 KB Output is correct
15 Correct 2 ms 848 KB Output is correct
16 Correct 3 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 556 KB Output is correct
7 Correct 3 ms 612 KB Output is correct
8 Correct 3 ms 612 KB Output is correct
9 Correct 2 ms 668 KB Output is correct
10 Correct 3 ms 668 KB Output is correct
11 Correct 2 ms 708 KB Output is correct
12 Correct 3 ms 708 KB Output is correct
13 Correct 3 ms 716 KB Output is correct
14 Correct 2 ms 716 KB Output is correct
15 Correct 2 ms 716 KB Output is correct
16 Correct 3 ms 728 KB Output is correct
17 Correct 2 ms 884 KB Output is correct
18 Correct 2 ms 888 KB Output is correct
19 Correct 2 ms 1012 KB Output is correct
20 Correct 2 ms 1012 KB Output is correct
21 Correct 2 ms 1012 KB Output is correct
22 Correct 2 ms 1012 KB Output is correct
23 Correct 2 ms 1028 KB Output is correct
24 Correct 3 ms 1032 KB Output is correct
25 Correct 2 ms 1036 KB Output is correct
26 Correct 2 ms 1036 KB Output is correct
27 Correct 2 ms 1044 KB Output is correct
28 Correct 2 ms 1044 KB Output is correct
29 Correct 3 ms 1052 KB Output is correct
30 Correct 2 ms 1072 KB Output is correct
31 Correct 2 ms 1072 KB Output is correct
32 Correct 2 ms 1072 KB Output is correct
33 Correct 2 ms 1072 KB Output is correct
34 Correct 2 ms 1072 KB Output is correct
35 Correct 2 ms 1072 KB Output is correct
36 Correct 2 ms 1072 KB Output is correct
37 Correct 3 ms 1072 KB Output is correct
38 Correct 2 ms 1072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 556 KB Output is correct
7 Correct 3 ms 612 KB Output is correct
8 Correct 3 ms 612 KB Output is correct
9 Correct 2 ms 668 KB Output is correct
10 Correct 3 ms 668 KB Output is correct
11 Correct 2 ms 708 KB Output is correct
12 Correct 3 ms 708 KB Output is correct
13 Correct 3 ms 716 KB Output is correct
14 Correct 2 ms 716 KB Output is correct
15 Correct 2 ms 716 KB Output is correct
16 Correct 3 ms 728 KB Output is correct
17 Correct 3 ms 728 KB Output is correct
18 Correct 3 ms 764 KB Output is correct
19 Correct 3 ms 764 KB Output is correct
20 Correct 2 ms 764 KB Output is correct
21 Correct 2 ms 776 KB Output is correct
22 Correct 3 ms 796 KB Output is correct
23 Correct 3 ms 796 KB Output is correct
24 Correct 2 ms 796 KB Output is correct
25 Correct 2 ms 824 KB Output is correct
26 Correct 2 ms 828 KB Output is correct
27 Correct 3 ms 832 KB Output is correct
28 Correct 3 ms 836 KB Output is correct
29 Correct 2 ms 836 KB Output is correct
30 Correct 3 ms 836 KB Output is correct
31 Correct 2 ms 848 KB Output is correct
32 Correct 3 ms 856 KB Output is correct
33 Correct 2 ms 884 KB Output is correct
34 Correct 2 ms 888 KB Output is correct
35 Correct 2 ms 1012 KB Output is correct
36 Correct 2 ms 1012 KB Output is correct
37 Correct 2 ms 1012 KB Output is correct
38 Correct 2 ms 1012 KB Output is correct
39 Correct 2 ms 1028 KB Output is correct
40 Correct 3 ms 1032 KB Output is correct
41 Correct 2 ms 1036 KB Output is correct
42 Correct 2 ms 1036 KB Output is correct
43 Correct 2 ms 1044 KB Output is correct
44 Correct 2 ms 1044 KB Output is correct
45 Correct 3 ms 1052 KB Output is correct
46 Correct 2 ms 1072 KB Output is correct
47 Correct 2 ms 1072 KB Output is correct
48 Correct 2 ms 1072 KB Output is correct
49 Correct 2 ms 1072 KB Output is correct
50 Correct 2 ms 1072 KB Output is correct
51 Correct 2 ms 1072 KB Output is correct
52 Correct 2 ms 1072 KB Output is correct
53 Correct 3 ms 1072 KB Output is correct
54 Correct 2 ms 1072 KB Output is correct
55 Correct 2 ms 1072 KB Output is correct
56 Correct 2 ms 1072 KB Output is correct
57 Correct 3 ms 1072 KB Output is correct
58 Correct 3 ms 1072 KB Output is correct
59 Correct 3 ms 1072 KB Output is correct
60 Correct 2 ms 1128 KB Output is correct
61 Correct 3 ms 1128 KB Output is correct
62 Correct 3 ms 1128 KB Output is correct
63 Correct 2 ms 1128 KB Output is correct
64 Correct 3 ms 1128 KB Output is correct
65 Correct 2 ms 1128 KB Output is correct
66 Correct 2 ms 1128 KB Output is correct
67 Correct 2 ms 1156 KB Output is correct
68 Correct 2 ms 1156 KB Output is correct
69 Correct 3 ms 1176 KB Output is correct
70 Correct 4 ms 1176 KB Output is correct
71 Correct 3 ms 1176 KB Output is correct
72 Correct 2 ms 1176 KB Output is correct
73 Correct 2 ms 1180 KB Output is correct
74 Correct 3 ms 1184 KB Output is correct
75 Correct 3 ms 1188 KB Output is correct
76 Correct 3 ms 1196 KB Output is correct
77 Correct 3 ms 1196 KB Output is correct
78 Correct 3 ms 1196 KB Output is correct
79 Correct 2 ms 1196 KB Output is correct
80 Correct 3 ms 1216 KB Output is correct
81 Correct 2 ms 1216 KB Output is correct
82 Correct 3 ms 1232 KB Output is correct
83 Correct 3 ms 1232 KB Output is correct
84 Correct 3 ms 1256 KB Output is correct
85 Correct 2 ms 1256 KB Output is correct
86 Correct 2 ms 1256 KB Output is correct
87 Correct 2 ms 1256 KB Output is correct
88 Correct 3 ms 1256 KB Output is correct
89 Correct 2 ms 1256 KB Output is correct
90 Correct 4 ms 1256 KB Output is correct
91 Correct 3 ms 1256 KB Output is correct
92 Correct 3 ms 1296 KB Output is correct