Submission #3219558


Source Code Expand

//
// LIS and LDS
//
// verified:
//   ARC 091 E - LISDL
//     https://beta.atcoder.jp/contests/arc091/tasks/arc091_c
//

/*
    0 〜 N-1 の順列であって
    LIS (最長増加部分列) の長さが A
    LDS (最長減少部分列) の長さが B
    となるものを 1 つ求める
*/


#include <iostream>
#include <vector>
using namespace std;


// LIS and LDS
// A + B <= N+1, AB >= N are necessarily and sufficient
vector<long long> LISLDS(long long N, long long A, long long B) {
    vector<long long> res;
    for (long long i = B-1; i >= 0; --i) res.push_back(i);
    
    if (A == 1) return res;
    
    long long rem = N - B;
    long long p = rem / (A-1);
    long long r = rem % (A-1);
    
    long long b = r;
    long long c = A-1-r;
    
    for (int i = 0; i < b; ++i) {
        int size = (int)res.size();
        for (int j = 0; j < p+1; ++j) {
            res.push_back(size + p - j);
        }
    }
    for (int i = 0; i < c; ++i) {
        int size = (int)res.size();
        for (int j = 0; j < p; ++j) {
            res.push_back(size + p-1 - j);
        }
    }
    
    return res;
}


int main() {
    int N, A, B; cin >> N >> A >> B;
    if (A + B > N+1 || A * B < N) cout << -1 << endl;
    else {
        vector<long long> res = LISLDS(N, A, B);
        for (int i = 0; i < res.size(); ++i) {
            cout << res[i] + 1;
            if (i != (int)res.size() - 1) cout << " ";
        }
        cout << endl;
    }
}

Submission Info

Submission Time
Task E - LISDL
User drken
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1526 Byte
Status WA
Exec Time 30 ms
Memory 6384 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 3
AC × 50
WA × 5
Set Name Test Cases
Sample s1.txt, s2.txt, s3.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, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt AC 10 ms 1780 KB
02.txt AC 2 ms 512 KB
03.txt AC 15 ms 2420 KB
04.txt AC 2 ms 384 KB
05.txt AC 27 ms 5488 KB
06.txt AC 1 ms 256 KB
07.txt AC 1 ms 256 KB
08.txt AC 13 ms 2164 KB
09.txt AC 16 ms 2672 KB
10.txt AC 27 ms 4592 KB
11.txt WA 1 ms 256 KB
12.txt AC 30 ms 5232 KB
13.txt WA 1 ms 256 KB
14.txt AC 22 ms 3440 KB
15.txt AC 8 ms 1400 KB
16.txt AC 29 ms 6256 KB
17.txt AC 2 ms 384 KB
18.txt AC 10 ms 1652 KB
19.txt AC 20 ms 3312 KB
20.txt AC 1 ms 256 KB
21.txt AC 10 ms 1780 KB
22.txt AC 22 ms 3440 KB
23.txt AC 20 ms 3184 KB
24.txt AC 1 ms 256 KB
25.txt AC 27 ms 4592 KB
26.txt AC 1 ms 256 KB
27.txt AC 1 ms 256 KB
28.txt AC 11 ms 1780 KB
29.txt AC 23 ms 3568 KB
30.txt AC 25 ms 3952 KB
31.txt WA 1 ms 256 KB
32.txt AC 30 ms 6128 KB
33.txt WA 1 ms 256 KB
34.txt AC 25 ms 3952 KB
35.txt AC 11 ms 1652 KB
36.txt AC 30 ms 6384 KB
37.txt AC 2 ms 384 KB
38.txt AC 12 ms 1908 KB
39.txt AC 22 ms 3440 KB
40.txt AC 1 ms 256 KB
41.txt AC 1 ms 256 KB
42.txt AC 1 ms 256 KB
43.txt AC 1 ms 256 KB
44.txt AC 1 ms 256 KB
45.txt AC 27 ms 4464 KB
46.txt WA 1 ms 256 KB
47.txt AC 1 ms 256 KB
48.txt AC 25 ms 3952 KB
49.txt AC 4 ms 764 KB
50.txt AC 1 ms 256 KB
51.txt AC 1 ms 256 KB
52.txt AC 1 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB
s3.txt AC 1 ms 256 KB