답안 #494789

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
494789 2021-12-16T11:35:51 Z Khizri 분수 공원 (IOI21_parks) C++17
0 / 100
1 ms 292 KB
#include "parks.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
const int mxn=2e5+100;
int n,color[mxn],say;
int l[4]={0,0,2,-2};
int r[4]={2,-2,0,0};
bool qq=true;
vector<int>a,b,c,d;
map<pii,int>arr;
map<pii,bool>cl;
void dfs(int x,int y,int cost){
    color[cost]=1;
    say++;
    for(int i=0;i<4;i++){
        int u=x+l[i],v=y+r[i];
        int k=arr[{u,v}];
        if(k&&!color[k]){
            a.pb(cost-1);
            b.pb(k-1);
            int q1=x,q2=v+1;
            if(q1==2){
                q1--;
            }
            else{
                q1++;
            }
            if(cl[{q1,q2}]){
                qq=false;
            }
            cl[{q1,q2}]=1;
            c.pb(q1);
            d.pb(q2);
            dfs(u,v,k);
        }
    }
}
int construct_roads(vector<int> x, vector<int> y) {
    n=x.size();
    int a1=-1e7,b1=-1e7,a2=1e7,b2=1e7;
    for(int i=0;i<n;i++){
        a1=max(a1,x[i]);
        b1=max(b1,y[i]);
        a2=min(a2,x[i]);
        b2=min(b2,y[i]);
        arr[{x[i],y[i]}]=i+1;
    }
    dfs(a2,b2,arr[{a2,b2}]);
    if(say==n){
        build(a,b,c,d);
        return 1;
    }
    if(say==n){
        build(a,b,c,d);
        return 1;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 KB Output is correct
2 Incorrect 1 ms 204 KB Tree (a[0], b[0]) = (1, 5) is not adjacent to edge between u[0]=0 @(2, 2) and v[0]=1 @(2, 4)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 KB Output is correct
2 Incorrect 1 ms 204 KB Tree (a[0], b[0]) = (1, 5) is not adjacent to edge between u[0]=0 @(2, 2) and v[0]=1 @(2, 4)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 KB Output is correct
2 Incorrect 1 ms 204 KB Tree (a[0], b[0]) = (1, 5) is not adjacent to edge between u[0]=0 @(2, 2) and v[0]=1 @(2, 4)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 KB Output is correct
2 Incorrect 1 ms 204 KB Tree (a[0], b[0]) = (1, 5) is not adjacent to edge between u[0]=0 @(2, 2) and v[0]=1 @(2, 4)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 KB Output is correct
2 Incorrect 1 ms 204 KB Tree (a[0], b[0]) = (1, 5) is not adjacent to edge between u[0]=0 @(2, 2) and v[0]=1 @(2, 4)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 KB Output is correct
2 Incorrect 1 ms 204 KB Tree (a[0], b[0]) = (1, 5) is not adjacent to edge between u[0]=0 @(2, 2) and v[0]=1 @(2, 4)
3 Halted 0 ms 0 KB -