답안 #621182

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
621182 2022-08-03T13:39:02 Z moyindavid 분수 공원 (IOI21_parks) C++17
0 / 100
1411 ms 2097152 KB
#include "parks.h"
#include <bits/stdc++.h>
 
using namespace std;

void build(vector<int> u, vector<int> v, vector<int> a, vector<int> b);
 
vector<bool> vis(200000,false);int cnt=0;vector<int> node[200000];vector<int> u,v,a,b;
void dsf(int i, vector<int> x, vector<int> y){
    vis[i]=true;
    cnt++;
    for(auto j: node[i]){
        if(!vis[j]){
            u.push_back(i);v.push_back(j);
 
            if(x[i]==x[j]){
                b.push_back((y[i]+y[j])/2);
                if(x[i]==2)a.push_back(x[i]-1);
                else a.push_back(x[i]+1);
            }
            else{
                a.push_back((x[i]+x[j])/2);
                b.push_back(y[i]-1);
            }
            dsf(j,x,y);
        }
    }
}
 
int construct_roads(vector<int> x, vector<int> y){
 
 
    map<pair<int,int>,bool> m;
    map<pair<int,int>,int> n;
 
    for(int i=0;i<x.size();i++){
        m[{x[i],y[i]}]=1;
        n[{x[i],y[i]}]=i;
    }
 
    for(int i=0;i<x.size();i++){
        if(m[{x[i]-2,y[i]}]){node[i].push_back(n[{x[i]-2,y[i]}]);node[n[{x[i]-2,y[i]}]].push_back(i);}
        if(m[{x[i]+2,y[i]}]){node[i].push_back(n[{x[i]+2,y[i]}]);node[n[{x[i]+2,y[i]}]].push_back(i);}
        if(m[{x[i],y[i]-2}]){node[i].push_back(n[{x[i],y[i]-2}]);node[n[{x[i],y[i]-2}]].push_back(i);}
        if(m[{x[i],y[i]+2}]){node[i].push_back(n[{x[i],y[i]+2}]);node[n[{x[i],y[i]+2}]].push_back(i);}
    }
 
    dsf(0,x,y);
    if(cnt==x.size()){
        build(u,v,a,b);
        return 1;
    }
    return 0;
}

Compilation message

parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:36:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i=0;i<x.size();i++){
      |                 ~^~~~~~~~~
parks.cpp:41:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(int i=0;i<x.size();i++){
      |                 ~^~~~~~~~~
parks.cpp:49:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     if(cnt==x.size()){
      |        ~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 5024 KB Output is correct
5 Correct 3 ms 5024 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Runtime error 1411 ms 2097152 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 5024 KB Output is correct
5 Correct 3 ms 5024 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Runtime error 1411 ms 2097152 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 5024 KB Output is correct
5 Correct 3 ms 5024 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Runtime error 1411 ms 2097152 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 5024 KB Output is correct
5 Correct 3 ms 5024 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Runtime error 1411 ms 2097152 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 5024 KB Output is correct
5 Correct 3 ms 5024 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Runtime error 1411 ms 2097152 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 5024 KB Output is correct
5 Correct 3 ms 5024 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Runtime error 1411 ms 2097152 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -