Submission #1694099


Source Code Expand

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    int N;
    cin >> N;
    vector<int> p(N+1);
    vector<int> pos(N+1);
    vector<int> a(N+1),b(N+1);
    REP(i,1,N+1){
        cin >> p[i];
        pos[p[i]] = i;
    }

    REP(i,1,N+1){
        a[i] = i * N;
        b[i] = (N + 1 - i) * N;
    }

    REP(i,1,N+1){
        a[p[i]] += i;
    }

    REP(i,1,N+1){
        cout << a[i];
        if(i != N) cout << " ";
    }
    cout << endl;
    REP(i,1,N+1){
        cout << b[i];
        if(i != N) cout << " ";
    }
    cout << endl;

    REP(i,1,N){
        if(!(a[p[i]] + b[p[i]] < a[p[i+1]] + b[p[i+1]] )){
            printf("------ bad case -----\n");
            printf("i = %d\n",i);
            printf("a[i] = %d,b[i] = %d\n",a[p[i]] , b[p[i]]);
            printf("[i] = %d,b[i] = %d\n",a[p[i+1]] , b[p[i+1]]);
            cout << endl;
        }
    }





    return 0;
}

Submission Info

Submission Time
Task B - Construct Sequences
User homesentinel
Language C++14 (GCC 5.4.1)
Score 400
Code Size 2269 Byte
Status AC
Exec Time 11 ms
Memory 896 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 22
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 AC 2 ms 256 KB
001.txt AC 2 ms 256 KB
002.txt AC 2 ms 256 KB
003.txt AC 2 ms 256 KB
004.txt AC 2 ms 256 KB
005.txt AC 11 ms 896 KB
006.txt AC 3 ms 384 KB
007.txt AC 10 ms 896 KB
008.txt AC 6 ms 640 KB
009.txt AC 10 ms 896 KB
010.txt AC 11 ms 896 KB
011.txt AC 11 ms 896 KB
012.txt AC 11 ms 896 KB
013.txt AC 11 ms 896 KB
014.txt AC 11 ms 896 KB
015.txt AC 11 ms 896 KB
016.txt AC 11 ms 896 KB
017.txt AC 11 ms 896 KB
018.txt AC 11 ms 896 KB
example0.txt AC 1 ms 256 KB
example1.txt AC 1 ms 256 KB
example2.txt AC 1 ms 256 KB