답안 #1051859

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1051859 2024-08-10T10:15:53 Z MarwenElarbi 분수 공원 (IOI21_parks) C++17
5 / 100
317 ms 46620 KB
#include <bits/stdc++.h>
using namespace std;
#include "parks.h"
#define pb push_back
#define fi first
#define se second
const int nax=2e5+5;
set<pair<int,int>> mp;
map<pair<int,int>,int> cor;
set<pair<int,int>> vis;
bool check(pair<int,int> a){
    if(!mp.count({a.fi-2,a.se})&&!mp.count({a.fi+2,a.se})&&!mp.count({a.fi,a.se-2})&&!mp.count({a.fi,a.se+2})) return false;
    return true; 
}
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;
    int n=y.size();
    for (int i = 0; i < n; ++i)
    {
        mp.insert({x[i],y[i]});
        cor[{x[i],y[i]}]=i;
    }
    bool test=true;
    for(auto i:mp){
        if(!check(i)){
            test=false;
            break;
        }
        if(mp.count({i.fi+2,i.se})){
            pair<int,int> cur={i.fi+1,i.se-1};
            if(vis.count(cur)) cur.se+=2;
            vis.insert(cur);
            a.pb(cur.fi);
            b.pb(cur.se);
            u.pb(cor[i]);
            v.pb(cor[{i.fi+2,i.se}]);
        }
        if(mp.count({i.fi,i.se+2})){
            pair<int,int> cur={i.fi-1,i.se+1};
            if(vis.count(cur)) cur.fi+=2;
            vis.insert(cur);
            a.pb(cur.fi);
            b.pb(cur.se);
            u.pb(cor[i]);
            v.pb(cor[{i.fi,i.se+2}]);
        }
    }
    if(!test) return 0;
    if(u.size()!=n-1) 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:53:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   53 |     if(u.size()!=n-1) return 0;
      |        ~~~~~~~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 108 ms 22144 KB Output is correct
10 Correct 8 ms 2652 KB Output is correct
11 Correct 53 ms 12164 KB Output is correct
12 Correct 14 ms 3940 KB Output is correct
13 Correct 43 ms 8544 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 105 ms 22264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 108 ms 22144 KB Output is correct
10 Correct 8 ms 2652 KB Output is correct
11 Correct 53 ms 12164 KB Output is correct
12 Correct 14 ms 3940 KB Output is correct
13 Correct 43 ms 8544 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 105 ms 22264 KB Output is correct
17 Incorrect 0 ms 348 KB Solution announced impossible, but it is possible.
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 108 ms 22144 KB Output is correct
10 Correct 8 ms 2652 KB Output is correct
11 Correct 53 ms 12164 KB Output is correct
12 Correct 14 ms 3940 KB Output is correct
13 Correct 43 ms 8544 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 105 ms 22264 KB Output is correct
17 Incorrect 0 ms 348 KB Solution announced impossible, but it is possible.
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 108 ms 22144 KB Output is correct
10 Correct 8 ms 2652 KB Output is correct
11 Correct 53 ms 12164 KB Output is correct
12 Correct 14 ms 3940 KB Output is correct
13 Correct 43 ms 8544 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 105 ms 22264 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 275 ms 46620 KB Output is correct
21 Correct 295 ms 46504 KB Output is correct
22 Correct 269 ms 46604 KB Output is correct
23 Correct 211 ms 39332 KB Output is correct
24 Correct 146 ms 26964 KB Output is correct
25 Correct 302 ms 39476 KB Output is correct
26 Correct 267 ms 39588 KB Output is correct
27 Correct 277 ms 45672 KB Output is correct
28 Correct 278 ms 45736 KB Output is correct
29 Correct 317 ms 45716 KB Output is correct
30 Correct 285 ms 45680 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Incorrect 15 ms 4036 KB Tree @(185725, 20413) appears more than once: for edges on positions 632 and 633
33 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 108 ms 22144 KB Output is correct
10 Correct 8 ms 2652 KB Output is correct
11 Correct 53 ms 12164 KB Output is correct
12 Correct 14 ms 3940 KB Output is correct
13 Correct 43 ms 8544 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 105 ms 22264 KB Output is correct
17 Incorrect 231 ms 37768 KB Solution announced impossible, but it is possible.
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 108 ms 22144 KB Output is correct
10 Correct 8 ms 2652 KB Output is correct
11 Correct 53 ms 12164 KB Output is correct
12 Correct 14 ms 3940 KB Output is correct
13 Correct 43 ms 8544 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 105 ms 22264 KB Output is correct
17 Incorrect 0 ms 348 KB Solution announced impossible, but it is possible.
18 Halted 0 ms 0 KB -