답안 #905050

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
905050 2024-01-12T13:27:11 Z browntoad Park (BOI16_park) C++14
컴파일 오류
0 ms 0 KB
8#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast", "unroll-loops")
using namespace std;
#define ll long long
#define int ll
#define FOR(i,a,b) for (int i = (a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define RREP1(i,n) for (int i=(n); i>=1; i--)
#define f first
#define s second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define SQ(x) (x)*(x)
#define pii pair<int, int>
#define pip pair<int, pii>
#define ppi pair<pii, int>
#define pdd pair<double ,double>
#define pcc pair<char, char>
#define endl '\n'
//#define TOAD
#ifdef TOAD
#define bug(x) cerr<<__LINE__<<": "<<#x<<" is "<<x<<endl
#define IOS()
#else
#define bug(...)
#define IOS() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#endif

const ll inf = 1ll<<60;
const int iinf=2147483647;
const ll mod = 1e9+7;
const ll maxn=2005;
const ll maxm=1e5+5;
const double PI=acos(-1);

ll pw(ll x, ll p, ll m=mod){
    if (p < 0) return 0;
    ll ret=1;
    while (p>0){
        if (p&1){
            ret*=x;
            ret%=m;
        }
        x*=x;
        x%=m;
        p>>=1;
    }
    return ret;
}

ll inv(ll a, ll m=mod){
    return pw(a,m-2,m);
}

vector<bool> ex(16);
struct Point{
    int x, y;
};
int dis2(Point a, Point b){
    return SQ(a.x-b.x)+SQ(a.y-b.y);
}
struct Circ{
    Point a;
    int r, typ, id;
};
bool cmpc(Circ a, Circ b){
    return a.r<b.r;
}
struct Pair{
    int a, b;
    int r; // when it will overlap
};
bool cmpp(Pair a, Pair b){
    return a.r<b.r;
}
struct Quer{
    int r;
    int pos, id;
};
bool cmpq(Quer a, Quer b){
    return a.r<b.r;
}

vector<int> par(maxn), msk(maxn);
int fin(int a){
    if (a == par[a]) return a;
    return par[a] = fin(par[a]);
}
void merg(int a, int b){
    a = fin(a); b = fin(b);
    par[a] = b;
    msk[b] |= msk[a];
    ex[msk[b]] = 1;
}

int n, q, mx, my;
vector<Circ> vc, tmp;
vector<Pair> pr;
vector<Quer> quer;
vector<string> ans(maxm);
bool ex2(int a, int b){
    if (a == 1 && b == 3){
        REP(i, 16){
            if (ex[i] && __builtin_popcount(i) >= 2 && (i != 9 && i != 6)) return 0;
        }
    }
    else {
        REP(i, 16){
            if (ex[i] && __builtin_popcount(i) >= 2 && (i != 12 && i != 3)) return 0;
        }
    }
    return 1;
}
bool ex1(int a, int b){
    // a < b; a and b share an edge
    if (b-a == 2) return ex2(a, b);
    int typ;
    if (a == 1 && b == 2) typ = 2;
    if (a == 2 && b == 3) typ = 1;
    if (a == 3 && b == 4) typ = 0;
    if (a == 1 && b == 4) typ = 3;
    REP(i, 16){
        if (!ex[i]) continue;
        if (i&(1<<typ)){
            if (i != (1<<typ)) return 0;
        }
    }
    return 1;
}


signed main(){
    IOS();
    cin>>n>>q>>mx>>my;
    REP(i, n){
        par[i] = i;
    }
    tmp = vector<Circ> (n);
    REP(i, n){
        cin>>tmp[i].a.x>>tmp[i].a.y>>tmp[i].r;
    }
    REP(i, n){
        vc.pb({tmp[i].a, my-tmp[i].a.y-tmp[i].r+1, 1, tmp[i].id});
        vc.pb({tmp[i].a, mx-tmp[i].a.x-tmp[i].r+1, 2, tmp[i].id});
        vc.pb({tmp[i].a, tmp[i].a.y-tmp[i].r+1, 4, tmp[i].id});
        vc.pb({tmp[i].a, tmp[i].a.x-tmp[i].r+1, 8, tmp[i].id});
    }
    REP(i, n){
        FOR(j, i+1, n){
            int tt = dis2(tmp[i].a, tmp[j].a);
            int l = 1, r = 1000000000,mid;
            while(l < r){
                mid = (l+r)>>1;
                if (tmp[i].r+tmp[j].r+2*mid > 2000000000 || SQ(tmp[i].r+tmp[j].r+2*mid) > tt){
                    r = mid;
                }
                else {
                    l = mid+1;
                }
            }
            pr.pb({i, j, l});
        }
    }
    quer = vector<Quer> (q);
    REP(i, q){
        cin>>quer[i].r>>quer[i].pos;
        quer[i].id = i;
    }

    sort(ALL(vc), cmpc); sort(ALL(pr), cmpp); sort(ALL(quer), cmpq);
    int pa = 0, pb = 0;
    REP(i, q){
        while(pa < SZ(vc) && vc[pa].r <= quer[i].r){
            msk[fin(vc[pa].id)] |= vc[pa].typ;
            ex[msk[fin(vc[pa].id)]] = 1;
            pa++;
        }
        while(pb < SZ(pr) && pr[pb].r <= quer[i].r){
            merg(pr[pb].a, pr[pb].b);
            pb++;
        }
        string ou;
        REP1(j, quer[i].pos-1){
            if (ex1(j, quer[i].pos)) ou += (char)(j+'0');
        }
        ou += (char)(quer[i].pos + '0');
        FOR(j, quer[i].pos+1, 5){
            if (ex1(quer[i].pos, j)) ou += (char)(j+'0');
        }
        ans[quer[i].id] = ou;
    }
    REP(i, q) cout<<ans[i]<<endl;


}
/*
5 3
16 11
11 8 1
6 10 1
7 3 2
10 4 1
15 5 1
1 1
2 2
2 1
*/

Compilation message

park.cpp:1:2: error: stray '#' in program
    1 | 8#include <bits/stdc++.h>
      |  ^
park.cpp:1:1: error: expected unqualified-id before numeric constant
    1 | 8#include <bits/stdc++.h>
      | ^
park.cpp:37:17: error: 'acos' was not declared in this scope
   37 | const double PI=acos(-1);
      |                 ^~~~
park.cpp:58:1: error: 'vector' does not name a type
   58 | vector<bool> ex(16);
      | ^~~~~~
park.cpp:87:1: error: 'vector' does not name a type
   87 | vector<int> par(maxn), msk(maxn);
      | ^~~~~~
park.cpp: In function 'long long int fin(long long int)':
park.cpp:89:14: error: 'par' was not declared in this scope
   89 |     if (a == par[a]) return a;
      |              ^~~
park.cpp:90:12: error: 'par' was not declared in this scope
   90 |     return par[a] = fin(par[a]);
      |            ^~~
park.cpp: In function 'void merg(long long int, long long int)':
park.cpp:94:5: error: 'par' was not declared in this scope
   94 |     par[a] = b;
      |     ^~~
park.cpp:95:5: error: 'msk' was not declared in this scope
   95 |     msk[b] |= msk[a];
      |     ^~~
park.cpp:96:5: error: 'ex' was not declared in this scope
   96 |     ex[msk[b]] = 1;
      |     ^~
park.cpp: At global scope:
park.cpp:100:1: error: 'vector' does not name a type
  100 | vector<Circ> vc, tmp;
      | ^~~~~~
park.cpp:101:1: error: 'vector' does not name a type
  101 | vector<Pair> pr;
      | ^~~~~~
park.cpp:102:1: error: 'vector' does not name a type
  102 | vector<Quer> quer;
      | ^~~~~~
park.cpp:103:1: error: 'vector' does not name a type
  103 | vector<string> ans(maxm);
      | ^~~~~~
park.cpp: In function 'bool ex2(long long int, long long int)':
park.cpp:107:17: error: 'ex' was not declared in this scope; did you mean 'ex2'?
  107 |             if (ex[i] && __builtin_popcount(i) >= 2 && (i != 9 && i != 6)) return 0;
      |                 ^~
      |                 ex2
park.cpp:112:17: error: 'ex' was not declared in this scope; did you mean 'ex2'?
  112 |             if (ex[i] && __builtin_popcount(i) >= 2 && (i != 12 && i != 3)) return 0;
      |                 ^~
      |                 ex2
park.cpp: In function 'bool ex1(long long int, long long int)':
park.cpp:126:14: error: 'ex' was not declared in this scope; did you mean 'ex1'?
  126 |         if (!ex[i]) continue;
      |              ^~
      |              ex1
park.cpp: In function 'int main()':
park.cpp:29:15: error: 'ios' has not been declared
   29 | #define IOS() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
      |               ^~~
park.cpp:136:5: note: in expansion of macro 'IOS'
  136 |     IOS();
      |     ^~~
park.cpp:29:40: error: 'cin' was not declared in this scope; did you mean 'fin'?
   29 | #define IOS() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
      |                                        ^~~
park.cpp:136:5: note: in expansion of macro 'IOS'
  136 |     IOS();
      |     ^~~
park.cpp:29:52: error: 'cout' was not declared in this scope
   29 | #define IOS() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
      |                                                    ^~~~
park.cpp:136:5: note: in expansion of macro 'IOS'
  136 |     IOS();
      |     ^~~
park.cpp:139:9: error: 'par' was not declared in this scope
  139 |         par[i] = i;
      |         ^~~
park.cpp:141:5: error: 'tmp' was not declared in this scope
  141 |     tmp = vector<Circ> (n);
      |     ^~~
park.cpp:141:11: error: 'vector' was not declared in this scope
  141 |     tmp = vector<Circ> (n);
      |           ^~~~~~
park.cpp:141:22: error: expected primary-expression before '>' token
  141 |     tmp = vector<Circ> (n);
      |                      ^
park.cpp:146:9: error: 'vc' was not declared in this scope
  146 |         vc.pb({tmp[i].a, my-tmp[i].a.y-tmp[i].r+1, 1, tmp[i].id});
      |         ^~
park.cpp:164:13: error: 'pr' was not declared in this scope; did you mean 'r'?
  164 |             pr.pb({i, j, l});
      |             ^~
      |             r
park.cpp:167:5: error: 'quer' was not declared in this scope; did you mean 'Quer'?
  167 |     quer = vector<Quer> (q);
      |     ^~~~
      |     Quer
park.cpp:167:23: error: expected primary-expression before '>' token
  167 |     quer = vector<Quer> (q);
      |                       ^
park.cpp:173:14: error: 'vc' was not declared in this scope
  173 |     sort(ALL(vc), cmpc); sort(ALL(pr), cmpp); sort(ALL(quer), cmpq);
      |              ^~
park.cpp:14:16: note: in definition of macro 'ALL'
   14 | #define ALL(x) x.begin(),x.end()
      |                ^
park.cpp:173:5: error: 'sort' was not declared in this scope; did you mean 'short'?
  173 |     sort(ALL(vc), cmpc); sort(ALL(pr), cmpp); sort(ALL(quer), cmpq);
      |     ^~~~
      |     short
park.cpp:173:35: error: 'pr' was not declared in this scope; did you mean 'pw'?
  173 |     sort(ALL(vc), cmpc); sort(ALL(pr), cmpp); sort(ALL(quer), cmpq);
      |                                   ^~
park.cpp:14:16: note: in definition of macro 'ALL'
   14 | #define ALL(x) x.begin(),x.end()
      |                ^
park.cpp:177:13: error: 'msk' was not declared in this scope
  177 |             msk[fin(vc[pa].id)] |= vc[pa].typ;
      |             ^~~
park.cpp:178:13: error: 'ex' was not declared in this scope; did you mean 'ex1'?
  178 |             ex[msk[fin(vc[pa].id)]] = 1;
      |             ^~
      |             ex1
park.cpp:185:9: error: 'string' was not declared in this scope
  185 |         string ou;
      |         ^~~~~~
park.cpp:187:38: error: 'ou' was not declared in this scope
  187 |             if (ex1(j, quer[i].pos)) ou += (char)(j+'0');
      |                                      ^~
park.cpp:189:9: error: 'ou' was not declared in this scope
  189 |         ou += (char)(quer[i].pos + '0');
      |         ^~
park.cpp:193:9: error: 'ans' was not declared in this scope
  193 |         ans[quer[i].id] = ou;
      |         ^~~
park.cpp:195:21: error: 'ans' was not declared in this scope
  195 |     REP(i, q) cout<<ans[i]<<endl;
      |                     ^~~