답안 #199588

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
199588 2020-02-02T05:54:54 Z SamAnd Drvca (COCI19_drvca) C++17
0 / 110
50 ms 3316 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;

int n;
int a[N];

void stg(const vector<int>& v1, const vector<int>& v2)
{
    if (v1.empty())
        return;
    if (v2.empty())
        return;
    for (int i = 0; i < v1.size() - 1; ++i)
    {
        if (v1[i + 1] - v1[i] != v1[1] - v1[0])
            return;
    }
    for (int i = 0; i < v2.size() - 1; ++i)
    {
        if (v2[i + 1] - v2[i] != v2[1] - v2[0])
            return;
    }
    printf("%d\n", v1.size());
    for (int i = 0; i < v1.size(); ++i)
        printf("%d ", v1[i]);
    printf("\n");
    printf("%d\n", v2.size());
    for (int i = 0; i < v2.size(); ++i)
        printf("%d ", v2[i]);
    printf("\n");
    exit(0);
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    sort(a + 1, a + n + 1);
    vector<int> v1, v2;
    v1.push_back(a[1]);
    v1.push_back(a[2]);
    for (int i = 3; i <= n; ++i)
    {
        if (a[i] - v1.back() == a[2] - a[1])
            v1.push_back(a[i]);
        else
            v2.push_back(a[i]);
    }
    stg(v1, v2);
    v1.clear();
    v2.clear();
    v1.push_back(a[1]);
    v2.push_back(a[2]);
    if (n == 2)
        stg(v1, v2);
    v1.push_back(a[3]);
    for (int i = 4; i <= n; ++i)
    {
        if (a[i] - v1.back() == a[3] - a[1])
            v1.push_back(a[i]);
        else
            v2.push_back(a[i]);
    }
    stg(v1, v2);
    v1.clear();
    v2.clear();
    v1.push_back(a[1]);
    v2.push_back(a[2]);
    v2.push_back(a[3]);
    for (int i = 4; i <= n; ++i)
    {
        if (a[i] - v2.back() == a[3] - a[2])
            v2.push_back(a[i]);
        else
            v1.push_back(a[i]);
    }
    stg(v1, v2);
    printf("-1\n");
    return 0;
}

Compilation message

drvca.cpp: In function 'void stg(const std::vector<int>&, const std::vector<int>&)':
drvca.cpp:14:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < v1.size() - 1; ++i)
                     ~~^~~~~~~~~~~~~~~
drvca.cpp:19:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < v2.size() - 1; ++i)
                     ~~^~~~~~~~~~~~~~~
drvca.cpp:24:29: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d\n", v1.size());
                    ~~~~~~~~~^
drvca.cpp:25:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < v1.size(); ++i)
                     ~~^~~~~~~~~~~
drvca.cpp:28:29: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d\n", v2.size());
                    ~~~~~~~~~^
drvca.cpp:29:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < v2.size(); ++i)
                     ~~^~~~~~~~~~~
drvca.cpp: In function 'int main()':
drvca.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
drvca.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]);
         ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Incorrect 6 ms 256 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Incorrect 6 ms 256 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 3316 KB Output is correct
2 Correct 46 ms 3188 KB Output is correct
3 Correct 48 ms 3316 KB Output is correct
4 Correct 44 ms 3188 KB Output is correct
5 Correct 44 ms 3316 KB Output is correct
6 Correct 47 ms 3184 KB Output is correct
7 Correct 46 ms 3292 KB Output is correct
8 Correct 50 ms 3188 KB Output is correct
9 Incorrect 32 ms 2220 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Incorrect 6 ms 256 KB Output isn't correct
10 Halted 0 ms 0 KB -