Submission #1438243


Source Code Expand

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n;
    cin >> n;
    vector<int> pi(n), p(n), a(n), b(n);
    rep(i, 0, n) cin >> pi[i];
    rep(i, 0, n){
        p[pi[i] - 1] = i;
    }
    a[0] = 1;
    b[n - 1] = 1;
    rep(i, 1, n){
        if(p[i] - p[i - 1] > 0){
            a[i] = a[i - 1] + 2 * (p[i] - p[i - 1]);
        }else{
            a[i] = a[i - 1] + 1;
        }
    }
    repb(i, n - 2, 0){
        if(p[i + 1] < p[i]){
            b[i] = b[i + 1] + 2 * (p[i] - p[i + 1]);
        }else{
            b[i] = b[i + 1] + 1;
        }
    }
    rep(i, 0, n){
        cout << a[i];
        if(i != n - 1) cout << " ";
    }
    cout << endl;
    rep(i, 0, n){
        cout << b[i];
        if(i != n - 1) cout << " ";
    }
    cout << endl;
}

Submission Info

Submission Time
Task B - Construct Sequences
User treeone
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1070 Byte
Status WA
Exec Time 11 ms
Memory 1280 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 7
WA × 15
Set Name Test Cases
Sample example0.txt, example1.txt, example2.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, example0.txt, example1.txt, example2.txt
Case Name Status Exec Time Memory
000.txt WA 2 ms 384 KB
001.txt WA 2 ms 256 KB
002.txt WA 2 ms 256 KB
003.txt WA 1 ms 256 KB
004.txt WA 2 ms 256 KB
005.txt WA 10 ms 1280 KB
006.txt WA 3 ms 384 KB
007.txt WA 9 ms 1152 KB
008.txt WA 6 ms 768 KB
009.txt WA 10 ms 1152 KB
010.txt WA 11 ms 1280 KB
011.txt WA 11 ms 1280 KB
012.txt WA 11 ms 1280 KB
013.txt WA 11 ms 1280 KB
014.txt WA 11 ms 1280 KB
015.txt AC 11 ms 1280 KB
016.txt AC 11 ms 1280 KB
017.txt AC 10 ms 1280 KB
018.txt AC 10 ms 1280 KB
example0.txt AC 1 ms 256 KB
example1.txt AC 1 ms 256 KB
example2.txt AC 1 ms 256 KB