Submission #980051


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

long long p[40000];
long long a[40000], b[40000];
int main()
{
    freopen("data.txt", "r", stdin);
    /*freopen("data.txt", "w", stdout);
    puts("20000");
    printf("%d %d ", 1, 20000);
    for(int i = 2;i < 20000;++i)
        printf("%d ", i);
    return 0;*/
    long long n;
    scanf("%lld", &n);
    for(long long i = 1; i <= n; ++i)
        scanf("%lld", &p[i]);
    for(long long i = 1; i <= n; ++i)
    {
        if(i == 1)
        {
            a[ p[i] ] = 0;
            b[ p[i] ] = 0;
        }
        else
        {
            if(p[i] > p[i - 1])
            {
                a[ p[i] ] = a[ p[i - 1] ] + (p[i] - p[i - 1]) * 20000;
                b[ p[i] ] = b[ p[i - 1] ] - (p[i] - p[i - 1]) * 19999;
            }
            else
            {
                a[ p[i] ] = a[ p[i - 1] ] - (p[i - 1] - p[i]) * 20000;
                b[ p[i] ] = b[ p[i - 1] ] + (p[i - 1] - p[i]) * 19999;
            }
        }
    }
    long long t = 1000000000000ll;
    for(long long i = 1;i <= n;++i)
        t = min(t, min((a[i] - 1), (b[i] - 1)));
    for(long long i = 1;i <= n;++i)
    {
        a[i] -= t;
        b[i] -= t;
    }
    for(long long i = 1; i <= n; ++i)
    {
        if(i == 1)
            printf("%lld", a[i]);
        else
            printf(" %lld", a[i]);
    }
    printf("\n");
    for(long long i = 1; i <= n; ++i)
    {
        if(i == 1)
            printf("%lld", b[i]);
        else
            printf(" %lld", b[i]);
    }
    printf("\n");
    return 0;
}

Submission Info

Submission Time
Task B - Construct Sequences
User Wonter
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1611 Byte
Status RE
Exec Time 305 ms
Memory 384 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:8:36: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
     freopen("data.txt", "r", stdin);
                                    ^
./Main.cpp:16:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld", &n);
                      ^
./Main.cpp:18:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &p[i]);
                             ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
RE × 3
RE × 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 RE 305 ms 256 KB
001.txt RE 162 ms 256 KB
002.txt RE 160 ms 256 KB
003.txt RE 161 ms 256 KB
004.txt RE 162 ms 256 KB
005.txt RE 163 ms 256 KB
006.txt RE 160 ms 384 KB
007.txt RE 162 ms 256 KB
008.txt RE 160 ms 256 KB
009.txt RE 160 ms 256 KB
010.txt RE 159 ms 256 KB
011.txt RE 160 ms 384 KB
012.txt RE 160 ms 256 KB
013.txt RE 160 ms 256 KB
014.txt RE 161 ms 256 KB
015.txt RE 160 ms 256 KB
016.txt RE 160 ms 256 KB
017.txt RE 161 ms 256 KB
018.txt RE 158 ms 384 KB
example0.txt RE 160 ms 256 KB
example1.txt RE 160 ms 256 KB
example2.txt RE 160 ms 256 KB