Submission #2273155


Source Code Expand

#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

void ng() {
        printf("-1\n");
        exit(0);
}

int main() {
        int n;
        scanf("%d", &n);
        vector<set<int>> ab(n), ba(n);
        vector<pair<int, int>> p;
        for (int i = 0; i < n; i ++) {
                int a, b;
                scanf("%d%d", &a, &b);
                p.emplace_back(a, b);
                ab[a].insert(b);
                ba[b].insert(a);
        }
        if (p[0].first != 0 || p[1].second != 0) ng();
        if (p[0].second != p[1].first) ng();
        for (int i = 2; i < n; i ++) {
                int a, b;
                tie(a, b) = p[i];
                cerr << a << ' ' << b << endl;
                if (a == 0 || b == 0) ng();
                if (ab[a - 1].count(b + 1) == 0 && ab[a - 1].count(b) == 0 && ab[a - 1].count(b - 1) == 0) ng();
                if (ba[b - 1].count(a + 1) == 0 && ba[b - 1].count(a) == 0 && ba[b - 1].count(a - 1) == 0) ng();
        }
        assert(false);

        return 0;
}

Submission Info

Submission Time
Task A - Distance Pairs
User KokiYmgch
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1220 Byte
Status RE
Exec Time 314 ms
Memory 19828 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:20:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &n);
                        ^
./Main.cpp:25:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
                 scanf("%d%d", &a, &b);
                                      ^

Judge Result

Set Name sample All
Score / Max Score 0 / 0 0 / 1500
Status
AC × 1
RE × 1
AC × 12
RE × 23
Set Name Test Cases
sample sample-01.txt, sample-02.txt
All sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, 01-31.txt, sample-01.txt, sample-02.txt
Case Name Status Exec Time Memory
01-01.txt AC 39 ms 19828 KB
01-02.txt AC 22 ms 10756 KB
01-03.txt RE 98 ms 256 KB
01-04.txt RE 97 ms 256 KB
01-05.txt RE 99 ms 384 KB
01-06.txt RE 199 ms 6272 KB
01-07.txt RE 301 ms 11000 KB
01-08.txt RE 300 ms 11128 KB
01-09.txt RE 283 ms 10800 KB
01-10.txt RE 275 ms 10752 KB
01-11.txt RE 283 ms 10744 KB
01-12.txt RE 283 ms 10956 KB
01-13.txt RE 308 ms 19828 KB
01-14.txt RE 313 ms 19828 KB
01-15.txt RE 308 ms 19828 KB
01-16.txt RE 275 ms 10744 KB
01-17.txt RE 269 ms 10744 KB
01-18.txt RE 270 ms 10744 KB
01-19.txt RE 309 ms 19828 KB
01-20.txt RE 314 ms 17908 KB
01-21.txt RE 314 ms 18164 KB
01-22.txt RE 296 ms 14452 KB
01-23.txt AC 111 ms 11128 KB
01-24.txt AC 183 ms 11128 KB
01-25.txt AC 31 ms 11000 KB
01-26.txt AC 32 ms 11000 KB
01-27.txt AC 132 ms 11000 KB
01-28.txt AC 113 ms 11128 KB
01-29.txt RE 99 ms 256 KB
01-30.txt AC 1 ms 256 KB
01-31.txt AC 1 ms 256 KB
sample-01.txt RE 99 ms 256 KB
sample-02.txt AC 1 ms 256 KB