답안 #481491

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
481491 2021-10-21T03:25:50 Z yungyao 분수 공원 (IOI21_parks) C++17
15 / 100
618 ms 71828 KB
using namespace std;
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>

typedef long long LL;
typedef pair<int,int> pii;
#define pb push_back
#define mkp make_pair
#define F first
#define S second
#define REP(n) for (int __=n;__--;)
#define REP1(i,n) for (int i=1;i<=n;++i)
#define REP0(i,n) for (int i=0;i<n;++i)
typedef vector <int> vi;

#include "parks.h"

int dx[4] = {2,0,-2,0},dy[4] = {0,2,0,-2};
int dfx[8] = {1,1,1,-1,-1,-1,1,-1}, dfy[8] = {1,-1,1,1,1,-1,-1,-1};
map <pii,bool> vis;

vi u,v,fx,fy;
set <pii> ben;
map <pii,int> mp;
void dfs(int x,int y){
    vis[mkp(x,y)] = true;
    REP0(i,4) if (vis.find(mkp(x+dx[i],y+dy[i])) != vis.end() and !vis[mkp(x+dx[i],y+dy[i])]){
        u.pb(mp[mkp(x,y)]);
        v.pb(mp[mkp(x+dx[i],y+dy[i])]);
        if (ben.find(mkp(x+dfx[i*2],y+dfy[i*2])) == ben.end()){
            ben.insert(mkp(x+dfx[i*2],y+dfy[i*2]));
            fx.pb(x+dfx[i*2]);
            fy.pb(y+dfy[i*2]);
        }
        else{
            ben.insert(mkp(x+dfx[i*2+1],y+dfy[i*2+1]));
            fx.pb(x+dfx[i*2+1]);
            fy.pb(y+dfy[i*2+1]);
        }
        dfs(x+dx[i],y+dy[i]);
    }
}

int construct_roads(vi x,vi y){
    int n = x.size();

    REP0(i,n) vis[mkp(x[i],y[i])] = false;
    REP0(i,n) mp[mkp(x[i],y[i])] = i;
    dfs(x[0],y[0]);

    for (auto [p,v]:vis) if (!v) return false;


    /*
    REP0(i,n){
        if (mp.find(mkp(x[i]+2,y[i])) != mp.end()){
            u.pb(i);
            v.pb(mp[mkp(x[i]+2,y[i])]);
            fx.pb(3);
            fy.pb(y[i]-1);
        }

        if (mp.find(mkp(x[i],y[i]+2)) != mp.end()){
            u.pb(i);
            v.pb(mp[mkp(x[i],y[i]+2)]);
            if (x[i] == 2) fx.pb(1);
            else fx.pb(5);
            fy.pb(y[i]+1);
        }
    }
    */

    build(u,v,fx,fy);
    return true;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 236 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 219 ms 34036 KB Output is correct
10 Correct 21 ms 3980 KB Output is correct
11 Correct 117 ms 18952 KB Output is correct
12 Correct 26 ms 5732 KB Output is correct
13 Correct 67 ms 12072 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 2 ms 588 KB Output is correct
16 Correct 215 ms 29584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 236 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 219 ms 34036 KB Output is correct
10 Correct 21 ms 3980 KB Output is correct
11 Correct 117 ms 18952 KB Output is correct
12 Correct 26 ms 5732 KB Output is correct
13 Correct 67 ms 12072 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 2 ms 588 KB Output is correct
16 Correct 215 ms 29584 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 590 ms 69568 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 2 ms 716 KB Output is correct
26 Correct 3 ms 844 KB Output is correct
27 Correct 3 ms 944 KB Output is correct
28 Correct 192 ms 27924 KB Output is correct
29 Correct 290 ms 38772 KB Output is correct
30 Correct 407 ms 54124 KB Output is correct
31 Correct 597 ms 69452 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
33 Correct 0 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 0 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 296 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 2 ms 716 KB Output is correct
44 Correct 2 ms 716 KB Output is correct
45 Correct 228 ms 30708 KB Output is correct
46 Correct 363 ms 45004 KB Output is correct
47 Correct 370 ms 44316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 236 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 219 ms 34036 KB Output is correct
10 Correct 21 ms 3980 KB Output is correct
11 Correct 117 ms 18952 KB Output is correct
12 Correct 26 ms 5732 KB Output is correct
13 Correct 67 ms 12072 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 2 ms 588 KB Output is correct
16 Correct 215 ms 29584 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 590 ms 69568 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 2 ms 716 KB Output is correct
26 Correct 3 ms 844 KB Output is correct
27 Correct 3 ms 944 KB Output is correct
28 Correct 192 ms 27924 KB Output is correct
29 Correct 290 ms 38772 KB Output is correct
30 Correct 407 ms 54124 KB Output is correct
31 Correct 597 ms 69452 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
33 Correct 0 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 0 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 296 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 2 ms 716 KB Output is correct
44 Correct 2 ms 716 KB Output is correct
45 Correct 228 ms 30708 KB Output is correct
46 Correct 363 ms 45004 KB Output is correct
47 Correct 370 ms 44316 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 0 ms 204 KB Output is correct
51 Correct 0 ms 204 KB Output is correct
52 Correct 1 ms 204 KB Output is correct
53 Incorrect 0 ms 204 KB Tree @(3, 5) appears more than once: for edges on positions 0 and 4
54 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 236 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 219 ms 34036 KB Output is correct
10 Correct 21 ms 3980 KB Output is correct
11 Correct 117 ms 18952 KB Output is correct
12 Correct 26 ms 5732 KB Output is correct
13 Correct 67 ms 12072 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 2 ms 588 KB Output is correct
16 Correct 215 ms 29584 KB Output is correct
17 Correct 0 ms 292 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 554 ms 71588 KB Output is correct
21 Correct 618 ms 66932 KB Output is correct
22 Correct 565 ms 64572 KB Output is correct
23 Correct 455 ms 53872 KB Output is correct
24 Correct 225 ms 30152 KB Output is correct
25 Correct 221 ms 30252 KB Output is correct
26 Correct 214 ms 30132 KB Output is correct
27 Incorrect 466 ms 49208 KB Tree @(1593, 3) appears more than once: for edges on positions 595 and 1096
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 236 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 219 ms 34036 KB Output is correct
10 Correct 21 ms 3980 KB Output is correct
11 Correct 117 ms 18952 KB Output is correct
12 Correct 26 ms 5732 KB Output is correct
13 Correct 67 ms 12072 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 2 ms 588 KB Output is correct
16 Correct 215 ms 29584 KB Output is correct
17 Correct 565 ms 69516 KB Output is correct
18 Correct 551 ms 62812 KB Output is correct
19 Incorrect 575 ms 71828 KB Tree @(50001, 100001) appears more than once: for edges on positions 2388 and 199994
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 236 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 219 ms 34036 KB Output is correct
10 Correct 21 ms 3980 KB Output is correct
11 Correct 117 ms 18952 KB Output is correct
12 Correct 26 ms 5732 KB Output is correct
13 Correct 67 ms 12072 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 2 ms 588 KB Output is correct
16 Correct 215 ms 29584 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 590 ms 69568 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 2 ms 716 KB Output is correct
26 Correct 3 ms 844 KB Output is correct
27 Correct 3 ms 944 KB Output is correct
28 Correct 192 ms 27924 KB Output is correct
29 Correct 290 ms 38772 KB Output is correct
30 Correct 407 ms 54124 KB Output is correct
31 Correct 597 ms 69452 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
33 Correct 0 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 0 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 296 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 2 ms 716 KB Output is correct
44 Correct 2 ms 716 KB Output is correct
45 Correct 228 ms 30708 KB Output is correct
46 Correct 363 ms 45004 KB Output is correct
47 Correct 370 ms 44316 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 0 ms 204 KB Output is correct
51 Correct 0 ms 204 KB Output is correct
52 Correct 1 ms 204 KB Output is correct
53 Incorrect 0 ms 204 KB Tree @(3, 5) appears more than once: for edges on positions 0 and 4
54 Halted 0 ms 0 KB -