답안 #1053118

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1053118 2024-08-11T08:54:15 Z vnm06 분수 공원 (IOI21_parks) C++17
0 / 100
1 ms 6744 KB
#include "parks.h"
#include<bits/stdc++.h>
using namespace std;

bool pos[200004];
int used[3][200004];
vector<int> gr[200004];


void dfs(int v)
{
    pos[v]=1;
    int brs=gr[v].size();
    for(int i=0; i<brs; i++)
    {
        int nv=gr[v][i];
        if(!pos[nv]) dfs(nv);
    }
}

int construct_roads(std::vector<int> x, std::vector<int> y) {
    if (x.size() == 1) {
	build({}, {}, {}, {});
        return 1;
    }
    std::vector<int> u, v, a, b;
    for(int i=0; i<x.size(); i++)
    {
        used[x[i]/2-1][y[i]]=i+1;
    }
    for(int i=2; i<=200000; i+=2)
    {
        if(used[0][i] && used[0][i+2])
        {
            u.push_back(used[0][i]-1);
            v.push_back(used[0][i+2]-1);
            a.push_back(1);
            b.push_back(i+1);
        }
        if(used[1][i] && used[1][i+2])
        {
            u.push_back(used[1][i]-1);
            v.push_back(used[1][i+2]-1);
            a.push_back(5);
            b.push_back(i+1);
        }
        if(used[1][i] && used[0][i])
        {
            u.push_back(used[1][i]-1);
            v.push_back(used[0][i]-1);
            a.push_back(3);
            b.push_back(i+1);
        }
    }
    for(int i=0; i<u.size(); i++)
    {
        gr[u[i]].push_back(v[i]);
        gr[v[i]].push_back(u[i]);
    }
    dfs(0);
    for(int i=0; i<x.size(); i++) if(!pos[i]) return 0;
    return 1;
}

Compilation message

parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:27:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i=0; i<x.size(); i++)
      |                  ~^~~~~~~~~
parks.cpp:55:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for(int i=0; i<u.size(); i++)
      |                  ~^~~~~~~~~
parks.cpp:61:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for(int i=0; i<x.size(); i++) if(!pos[i]) return 0;
      |                  ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Incorrect 1 ms 6744 KB Wrong answer detected in grader
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Incorrect 1 ms 6744 KB Wrong answer detected in grader
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Incorrect 1 ms 6744 KB Wrong answer detected in grader
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Incorrect 1 ms 6744 KB Wrong answer detected in grader
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Incorrect 1 ms 6744 KB Wrong answer detected in grader
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Incorrect 1 ms 6744 KB Wrong answer detected in grader
3 Halted 0 ms 0 KB -