답안 #1022445

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1022445 2024-07-13T14:05:17 Z edogawa_something 분수 공원 (IOI21_parks) C++17
15 / 100
173 ms 81852 KB
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
#define pb push_back
#define F first 
#define S second 
#define all(v) v.begin(),v.end()
const ll M=2e6+50;
vii adj[M];
bool vis[M];
void dfs(ll x){
    if(vis[x])
    return;
    vis[x]=1;
    for(auto it:adj[x]){
        dfs(it);
    }
}
int construct_roads(std::vector<int> x, std::vector<int> y) {
    vector<pair<int,int>>f,m,b;
    for(int i=0;i<x.size();i++){
        if(x[i]==2){
            f.pb({y[i],i});
        }
        else
        b.pb({y[i],i});
    }
    sort(all(f)),sort(all(b));
    vector<int>e1,e2,ax,ay;
    for(int i=0;i<ll(f.size())-1;i++){
        if(f[i+1].F-f[i].F==2){
        e1.pb(f[i].S);
        e2.pb(f[i+1].S);
        ax.pb(1);
        ay.pb(f[i].F+1);
        }
    }
    for(int i=0;i<ll(b.size())-1;i++){
        if(b[i+1].F-b[i].F==2){
        e1.pb(b[i].S);
        e2.pb(b[i+1].S);
        ax.pb(5);
        ay.pb(b[i].F+1);
        }
    }
    ll i=0,j=0;
    while(1){
        if(i==f.size()||j==b.size())
        break;
        if(f[i].F==b[j].F){
            e1.pb(f[i].S),e2.pb(b[j].S);
            ax.pb(3),ay.pb(f[i].F-1);
            i++,j++;
        }
        else if(f[i].F<b[j].F){
            i++;
        }
        else if(b[j].F<f[i].F){
            j++;
        }
    }
    for(int i=0;i<e1.size();i++)
    adj[e1[i]].pb(e2[i]),adj[e2[i]].pb(e1[i]);
    dfs(0);
    for(int i=0;i<x.size();i++){
        if(!vis[i])
        return 0;
    }
    build(e1,e2,ax,ay);
    return 1;
}

Compilation message

parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:24:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i=0;i<x.size();i++){
      |                 ~^~~~~~~~~
parks.cpp:51:13: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |         if(i==f.size()||j==b.size())
      |            ~^~~~~~~~~~
parks.cpp:51:26: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |         if(i==f.size()||j==b.size())
      |                         ~^~~~~~~~~~
parks.cpp:65:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     for(int i=0;i<e1.size();i++)
      |                 ~^~~~~~~~~~
parks.cpp:68:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |     for(int i=0;i<x.size();i++){
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 47196 KB Output is correct
2 Correct 23 ms 47192 KB Output is correct
3 Correct 22 ms 47196 KB Output is correct
4 Correct 22 ms 47196 KB Output is correct
5 Correct 23 ms 47376 KB Output is correct
6 Correct 26 ms 47196 KB Output is correct
7 Correct 25 ms 47196 KB Output is correct
8 Correct 23 ms 47212 KB Output is correct
9 Correct 75 ms 60828 KB Output is correct
10 Correct 37 ms 48792 KB Output is correct
11 Correct 50 ms 54652 KB Output is correct
12 Correct 28 ms 49380 KB Output is correct
13 Correct 32 ms 51628 KB Output is correct
14 Correct 22 ms 47452 KB Output is correct
15 Correct 22 ms 47452 KB Output is correct
16 Correct 80 ms 60072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 47196 KB Output is correct
2 Correct 23 ms 47192 KB Output is correct
3 Correct 22 ms 47196 KB Output is correct
4 Correct 22 ms 47196 KB Output is correct
5 Correct 23 ms 47376 KB Output is correct
6 Correct 26 ms 47196 KB Output is correct
7 Correct 25 ms 47196 KB Output is correct
8 Correct 23 ms 47212 KB Output is correct
9 Correct 75 ms 60828 KB Output is correct
10 Correct 37 ms 48792 KB Output is correct
11 Correct 50 ms 54652 KB Output is correct
12 Correct 28 ms 49380 KB Output is correct
13 Correct 32 ms 51628 KB Output is correct
14 Correct 22 ms 47452 KB Output is correct
15 Correct 22 ms 47452 KB Output is correct
16 Correct 80 ms 60072 KB Output is correct
17 Correct 22 ms 47196 KB Output is correct
18 Correct 22 ms 47192 KB Output is correct
19 Correct 22 ms 47196 KB Output is correct
20 Correct 23 ms 47420 KB Output is correct
21 Correct 24 ms 47196 KB Output is correct
22 Correct 29 ms 47300 KB Output is correct
23 Correct 173 ms 81628 KB Output is correct
24 Correct 23 ms 47196 KB Output is correct
25 Correct 24 ms 47448 KB Output is correct
26 Correct 23 ms 47836 KB Output is correct
27 Correct 24 ms 47700 KB Output is correct
28 Correct 78 ms 61168 KB Output is correct
29 Correct 108 ms 68160 KB Output is correct
30 Correct 145 ms 75068 KB Output is correct
31 Correct 168 ms 81852 KB Output is correct
32 Correct 22 ms 47192 KB Output is correct
33 Correct 22 ms 47416 KB Output is correct
34 Correct 22 ms 47192 KB Output is correct
35 Correct 23 ms 47300 KB Output is correct
36 Correct 22 ms 47196 KB Output is correct
37 Correct 25 ms 47448 KB Output is correct
38 Correct 23 ms 47192 KB Output is correct
39 Correct 22 ms 47192 KB Output is correct
40 Correct 23 ms 47196 KB Output is correct
41 Correct 24 ms 47196 KB Output is correct
42 Correct 25 ms 47372 KB Output is correct
43 Correct 24 ms 47452 KB Output is correct
44 Correct 26 ms 47456 KB Output is correct
45 Correct 80 ms 60144 KB Output is correct
46 Correct 106 ms 66520 KB Output is correct
47 Correct 106 ms 66368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 47196 KB Output is correct
2 Correct 23 ms 47192 KB Output is correct
3 Correct 22 ms 47196 KB Output is correct
4 Correct 22 ms 47196 KB Output is correct
5 Correct 23 ms 47376 KB Output is correct
6 Correct 26 ms 47196 KB Output is correct
7 Correct 25 ms 47196 KB Output is correct
8 Correct 23 ms 47212 KB Output is correct
9 Correct 75 ms 60828 KB Output is correct
10 Correct 37 ms 48792 KB Output is correct
11 Correct 50 ms 54652 KB Output is correct
12 Correct 28 ms 49380 KB Output is correct
13 Correct 32 ms 51628 KB Output is correct
14 Correct 22 ms 47452 KB Output is correct
15 Correct 22 ms 47452 KB Output is correct
16 Correct 80 ms 60072 KB Output is correct
17 Correct 22 ms 47196 KB Output is correct
18 Correct 22 ms 47192 KB Output is correct
19 Correct 22 ms 47196 KB Output is correct
20 Correct 23 ms 47420 KB Output is correct
21 Correct 24 ms 47196 KB Output is correct
22 Correct 29 ms 47300 KB Output is correct
23 Correct 173 ms 81628 KB Output is correct
24 Correct 23 ms 47196 KB Output is correct
25 Correct 24 ms 47448 KB Output is correct
26 Correct 23 ms 47836 KB Output is correct
27 Correct 24 ms 47700 KB Output is correct
28 Correct 78 ms 61168 KB Output is correct
29 Correct 108 ms 68160 KB Output is correct
30 Correct 145 ms 75068 KB Output is correct
31 Correct 168 ms 81852 KB Output is correct
32 Correct 22 ms 47192 KB Output is correct
33 Correct 22 ms 47416 KB Output is correct
34 Correct 22 ms 47192 KB Output is correct
35 Correct 23 ms 47300 KB Output is correct
36 Correct 22 ms 47196 KB Output is correct
37 Correct 25 ms 47448 KB Output is correct
38 Correct 23 ms 47192 KB Output is correct
39 Correct 22 ms 47192 KB Output is correct
40 Correct 23 ms 47196 KB Output is correct
41 Correct 24 ms 47196 KB Output is correct
42 Correct 25 ms 47372 KB Output is correct
43 Correct 24 ms 47452 KB Output is correct
44 Correct 26 ms 47456 KB Output is correct
45 Correct 80 ms 60144 KB Output is correct
46 Correct 106 ms 66520 KB Output is correct
47 Correct 106 ms 66368 KB Output is correct
48 Incorrect 27 ms 47196 KB Solution announced impossible, but it is possible.
49 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 47196 KB Output is correct
2 Correct 23 ms 47192 KB Output is correct
3 Correct 22 ms 47196 KB Output is correct
4 Correct 22 ms 47196 KB Output is correct
5 Correct 23 ms 47376 KB Output is correct
6 Correct 26 ms 47196 KB Output is correct
7 Correct 25 ms 47196 KB Output is correct
8 Correct 23 ms 47212 KB Output is correct
9 Correct 75 ms 60828 KB Output is correct
10 Correct 37 ms 48792 KB Output is correct
11 Correct 50 ms 54652 KB Output is correct
12 Correct 28 ms 49380 KB Output is correct
13 Correct 32 ms 51628 KB Output is correct
14 Correct 22 ms 47452 KB Output is correct
15 Correct 22 ms 47452 KB Output is correct
16 Correct 80 ms 60072 KB Output is correct
17 Incorrect 22 ms 47336 KB Solution announced impossible, but it is possible.
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 47196 KB Output is correct
2 Correct 23 ms 47192 KB Output is correct
3 Correct 22 ms 47196 KB Output is correct
4 Correct 22 ms 47196 KB Output is correct
5 Correct 23 ms 47376 KB Output is correct
6 Correct 26 ms 47196 KB Output is correct
7 Correct 25 ms 47196 KB Output is correct
8 Correct 23 ms 47212 KB Output is correct
9 Correct 75 ms 60828 KB Output is correct
10 Correct 37 ms 48792 KB Output is correct
11 Correct 50 ms 54652 KB Output is correct
12 Correct 28 ms 49380 KB Output is correct
13 Correct 32 ms 51628 KB Output is correct
14 Correct 22 ms 47452 KB Output is correct
15 Correct 22 ms 47452 KB Output is correct
16 Correct 80 ms 60072 KB Output is correct
17 Incorrect 95 ms 63108 KB Solution announced impossible, but it is possible.
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 47196 KB Output is correct
2 Correct 23 ms 47192 KB Output is correct
3 Correct 22 ms 47196 KB Output is correct
4 Correct 22 ms 47196 KB Output is correct
5 Correct 23 ms 47376 KB Output is correct
6 Correct 26 ms 47196 KB Output is correct
7 Correct 25 ms 47196 KB Output is correct
8 Correct 23 ms 47212 KB Output is correct
9 Correct 75 ms 60828 KB Output is correct
10 Correct 37 ms 48792 KB Output is correct
11 Correct 50 ms 54652 KB Output is correct
12 Correct 28 ms 49380 KB Output is correct
13 Correct 32 ms 51628 KB Output is correct
14 Correct 22 ms 47452 KB Output is correct
15 Correct 22 ms 47452 KB Output is correct
16 Correct 80 ms 60072 KB Output is correct
17 Correct 22 ms 47196 KB Output is correct
18 Correct 22 ms 47192 KB Output is correct
19 Correct 22 ms 47196 KB Output is correct
20 Correct 23 ms 47420 KB Output is correct
21 Correct 24 ms 47196 KB Output is correct
22 Correct 29 ms 47300 KB Output is correct
23 Correct 173 ms 81628 KB Output is correct
24 Correct 23 ms 47196 KB Output is correct
25 Correct 24 ms 47448 KB Output is correct
26 Correct 23 ms 47836 KB Output is correct
27 Correct 24 ms 47700 KB Output is correct
28 Correct 78 ms 61168 KB Output is correct
29 Correct 108 ms 68160 KB Output is correct
30 Correct 145 ms 75068 KB Output is correct
31 Correct 168 ms 81852 KB Output is correct
32 Correct 22 ms 47192 KB Output is correct
33 Correct 22 ms 47416 KB Output is correct
34 Correct 22 ms 47192 KB Output is correct
35 Correct 23 ms 47300 KB Output is correct
36 Correct 22 ms 47196 KB Output is correct
37 Correct 25 ms 47448 KB Output is correct
38 Correct 23 ms 47192 KB Output is correct
39 Correct 22 ms 47192 KB Output is correct
40 Correct 23 ms 47196 KB Output is correct
41 Correct 24 ms 47196 KB Output is correct
42 Correct 25 ms 47372 KB Output is correct
43 Correct 24 ms 47452 KB Output is correct
44 Correct 26 ms 47456 KB Output is correct
45 Correct 80 ms 60144 KB Output is correct
46 Correct 106 ms 66520 KB Output is correct
47 Correct 106 ms 66368 KB Output is correct
48 Incorrect 27 ms 47196 KB Solution announced impossible, but it is possible.
49 Halted 0 ms 0 KB -