답안 #1053254

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1053254 2024-08-11T10:06:50 Z aykhn 분수 공원 (IOI21_parks) C++17
0 / 100
0 ms 348 KB
#include "parks.h"
#include <bits/stdc++.h>

using namespace std;

int A[4] = {0, 0, 2, -2};
int B[4] = {2, -2, 0, 0};
array<int, 2> ben[4][2] = {{{-1, 1}, {1, 1}}, {{-1, -1}, {1, -1}}, {{1, 1}, {1, -1}}, {{-1, 1}, {-1, -1}}};

int construct_roads(vector<int> X, vector<int> Y) 
{
    map<array<int, 2>, int> mp, us;
    for (int i = 0; i < X.size(); i++) mp[{X[i], Y[i]}] = i + 1;
    vector<int> u, v, a, b;
    for (int i = 0; i < X.size(); i++)
    {
        int x = X[i], y = Y[i];
        for (int k = 0; k < 4; k++)
        {
            int x1 = x + A[k], y1 = y + B[k];
            if (!mp[{x1, y1}]) continue;
            u.push_back(i), v.push_back(mp[{x1, y1}]);
            for (array<int, 2> &j : ben[k])
            {
                int a1 = x + j[0], b1 = y + j[1];
                if (!us[{a1, b1}])
                {
                    a.push_back(a1);
                    b.push_back(b1);
                    break;
                }
            }
            assert(a.size() == u.size());
        }
    }
    build(u, v, a, b);
    return 1;
}

Compilation message

parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:13:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for (int i = 0; i < X.size(); i++) mp[{X[i], Y[i]}] = i + 1;
      |                     ~~^~~~~~~~~~
parks.cpp:15:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for (int i = 0; i < X.size(); i++)
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Integer parameter [name=v[j]] equals to 2, violates the range [0, 1]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Integer parameter [name=v[j]] equals to 2, violates the range [0, 1]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Integer parameter [name=v[j]] equals to 2, violates the range [0, 1]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Integer parameter [name=v[j]] equals to 2, violates the range [0, 1]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Integer parameter [name=v[j]] equals to 2, violates the range [0, 1]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Integer parameter [name=v[j]] equals to 2, violates the range [0, 1]
3 Halted 0 ms 0 KB -