답안 #436686

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
436686 2021-06-24T18:24:48 Z PiejanVDC 분수 공원 (IOI21_parks) C++17
컴파일 오류
0 ms 0 KB
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;

int construct_roads(vector<int>x, vector<int> y) {
   vector<int>possible_x(200005,0),possible_y(200005,0);
   for(int i = 1 ; i <= x.size() ; i++) possible_x[x[i]]=i;
   for(int i = 1 ; i <= y.size() ; i++) possible_y[y[i]]=i;
   vector<pair<int,int>>combined(y.size());
   for(int i = 0 ; i < y.size() ; i++) {
    combined[i].first=x[i],combined[i].second=y[i];
   }
   vector<int>u(y.size()),v(y.size()),a(y.size()),b(y.size());
   for(int i = 0 ; i < y.size() ; i++) {
    if(possible_x[combined[i].first-2]) {
        u[i]=possible_x[combined[i].first-2]-1;
        v[i]=i;
        a[i]=combined[i].first+1;
        b[i]=combined[i].second+1;
    } else if(possible_x[combined[i].first+2]) {
        u[i]=possible_x[combined[i].first+2]-1;
        v[i]=i
        a[i]=combined[i].first+1;
        b[i]=combined[i].second+1;
    } else if(possible_y[combined[i].second-2]) {
        u[i]=possible_y[combined[i].second-2]-1;
        v[i]=i
        a[i]=combined[i].first+1;
        b[i]=combined[i].second+1;
    } else if(possible_y[combined[i].second+2]) {
        u[i]=possible_y[combined[i].second+2]-1;
        v[i]=i
        a[i]=combined[i].first+1;
        b[i]=combined[i].second+1;
    } else {
        return 0;
    }
   }
   build(u,v,a,b);
   return 1;
}

Compilation message

parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:7:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |    for(int i = 1 ; i <= x.size() ; i++) possible_x[x[i]]=i;
      |                    ~~^~~~~~~~~~~
parks.cpp:8:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |    for(int i = 1 ; i <= y.size() ; i++) possible_y[y[i]]=i;
      |                    ~~^~~~~~~~~~~
parks.cpp:10:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |    for(int i = 0 ; i < y.size() ; i++) {
      |                    ~~^~~~~~~~~~
parks.cpp:14:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |    for(int i = 0 ; i < y.size() ; i++) {
      |                    ~~^~~~~~~~~~
parks.cpp:22:15: error: expected ';' before 'a'
   22 |         v[i]=i
      |               ^
      |               ;
   23 |         a[i]=combined[i].first+1;
      |         ~      
parks.cpp:27:15: error: expected ';' before 'a'
   27 |         v[i]=i
      |               ^
      |               ;
   28 |         a[i]=combined[i].first+1;
      |         ~      
parks.cpp:32:15: error: expected ';' before 'a'
   32 |         v[i]=i
      |               ^
      |               ;
   33 |         a[i]=combined[i].first+1;
      |         ~