Submission #36646

# Submission time Handle Problem Language Result Execution time Memory
36646 2017-12-13T02:18:14 Z imaxblue Park (BOI16_park) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() >> 3)*rand()

int n, k, w, h, N, o, R,
    x[2005], y[2005], r[2005], d[2005][4], dis[2005][2005];
int ans[4][4], D;
pq<pii> q;
void dijk(int O){
    while(!q.empty()) q.pop();
    fox(l, n){
        q.push(mp(-d[l][O], l));
        d[l][O]=(1 << 30);
    }
    while(!q.empty()){
        D=-q.top().x; N=q.top().y; q.pop();
        if (D>=d[N][O]) continue;
        d[N][O]=D;
        fox(l, n){
            if (l==N) continue;
            if (max(D, dis[N][l])<d[l][O])
                q.push(mp(-max(D, dis[N][l]), l));
        }
    }
}
int main(){
    flood(d); flood(ans);
    scanf("%i%i%i%i", &n, &k, &w, &h);
    fox(l, n){
        scanf("%i%i%i", &x[l], &y[l], &r[l]);
        d[l][0]=x[l]-r[l];
        d[l][1]=y[l]-r[l];
        d[l][2]=w-x[l]-r[l];
        d[l][3]=h-y[l]-r[l];
    }
    fox(X, n){
        fox(Y, n){
            dis[X][Y]=int(sqrt(1LL*(x[X]-x[Y])*(x[X]-x[Y])+
                     1LL*(y[X]-y[Y])*(y[X]-y[Y])))-r[X]-r[Y];
        }
    }
    fox(l, 3) dijk(l);
    fox(l, n){
        fox(l2, 3){
            fox(l4, 4)
if (l4!=l2) ans[l2][l4]=ans[l4][l2]=min(ans[l2][l4], max(d[l][l2], d[l][l2+1]));

        }
            fox(l3, 3){
                ans[l3][3]=ans[3][l3]=min(ans[3][l3], max(d[l][0], d[l][3]));
            }
            ans[0][2]=ans[2][0]=min(ans[0][2], max(d[l][0], d[l][2]));
            ans[0][3]=ans[3][0]=min(ans[0][3], max(d[l][0], d[l][2]));
            ans[1][2]=ans[1][2]=min(ans[1][2], max(d[l][0], d[l][2]));
            ans[1][3]=ans[3][1]=min(ans[1][3], max(d[l][0], d[l][2]));
            ans[0][1]=ans[1][0]=min(ans[0][1], max(d[l][1], d[l][3]));
            ans[0][2]=ans[2][0]=min(ans[0][2], max(d[l][1], d[l][3]));
            ans[2][3]=ans[3][2]=min(ans[2][3], max(d[l][1], d[l][3]));
            ans[1][3]=ans[3][1]=min(ans[1][3], max(d[l][1], d[l][3]));
    }
    /*fox(l, n){
        fox(l2, n) printf("%i ", ans[l][l2]);
        printf("\n");
    }*/
    fox(l, k){
        scanf("%i%i", &R, &o);
        --o;
        R*=2;
        fox(l, 4){
            if (R<=ans[o][l]) printf("%i", l+1);
        }
        printf("\n");
    }
    return 0;
}
/*
5 3
16 11
11 8 1
6 10 1
7 3 2
10 4 1
15 5 1
2 2
2 1
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() >> 3)*rand()

int n, k, w, h, N, o, R,
    x[2005], y[2005], r[2005], d[2005][4], dis[2005][2005];
int ans[4][4], D;
pq<pii> q;
void dijk(int O){
    while(!q.empty()) q.pop();
    fox(l, n){
        q.push(mp(-d[l][O], l));
        d[l][O]=(1 << 30);
    }
    while(!q.empty()){
        D=-q.top().x; N=q.top().y; q.pop();
        if (D>=d[N][O]) continue;
        d[N][O]=D;
        fox(l, n){
            if (l==N) continue;
            if (max(D, dis[N][l])<d[l][O])
                q.push(mp(-max(D, dis[N][l]), l));
        }
    }
}
int main(){
    flood(d); flood(ans);
    scanf("%i%i%i%i", &n, &k, &w, &h);
    fox(l, n){
        scanf("%i%i%i", &x[l], &y[l], &r[l]);
        d[l][0]=x[l]-r[l];
        d[l][1]=y[l]-r[l];
        d[l][2]=w-x[l]-r[l];
        d[l][3]=h-y[l]-r[l];
    }
    fox(X, n){
        fox(Y, n){
            dis[X][Y]=int(sqrt(1LL*(x[X]-x[Y])*(x[X]-x[Y])+
                     1LL*(y[X]-y[Y])*(y[X]-y[Y])))-r[X]-r[Y];
        }
    }
    fox(l, 3) dijk(l);
    fox(l, n){
        fox(l2, 3){
            fox(l4, 4)
if (l4!=l2) ans[l2][l4]=ans[l4][l2]=min(ans[l2][l4], max(d[l][l2], d[l][l2+1]));

        }
            fox(l3, 3){
                ans[l3][3]=ans[3][l3]=min(ans[3][l3], max(d[l][0], d[l][3]));
            }
            ans[0][2]=ans[2][0]=min(ans[0][2], max(d[l][0], d[l][2]));
            ans[0][3]=ans[3][0]=min(ans[0][3], max(d[l][0], d[l][2]));
            ans[1][2]=ans[1][2]=min(ans[1][2], max(d[l][0], d[l][2]));
            ans[1][3]=ans[3][1]=min(ans[1][3], max(d[l][0], d[l][2]));
            ans[0][1]=ans[1][0]=min(ans[0][1], max(d[l][1], d[l][3]));
            ans[0][2]=ans[2][0]=min(ans[0][2], max(d[l][1], d[l][3]));
            ans[2][3]=ans[3][2]=min(ans[2][3], max(d[l][1], d[l][3]));
            ans[1][3]=ans[3][1]=min(ans[1][3], max(d[l][1], d[l][3]));
    }
    /*fox(l, n){
        fox(l2, n) printf("%i ", ans[l][l2]);
        printf("\n");
    }*/
    fox(l, k){
        scanf("%i%i", &R, &o);
        --o;
        R*=2;
        fox(l, 4){
            if (R<=ans[o][l]) printf("%i", l+1);
        }
        printf("\n");
    }
    return 0;
}
/*
5 3
16 11
11 8 1
6 10 1
7 3 2
10 4 1
15 5 1
2 2
2 1
*/

Compilation message

park.cpp: In function 'int main()':
park.cpp:76:70: warning: operation on 'ans[1][2]' may be undefined [-Wsequence-point]
             ans[1][2]=ans[1][2]=min(ans[1][2], max(d[l][0], d[l][2]));
                                                                      ^
park.cpp: At global scope:
park.cpp:135:5: error: redefinition of 'int n'
 int n, k, w, h, N, o, R,
     ^
park.cpp:27:5: note: 'int n' previously declared here
 int n, k, w, h, N, o, R,
     ^
park.cpp:135:8: error: redefinition of 'int k'
 int n, k, w, h, N, o, R,
        ^
park.cpp:27:8: note: 'int k' previously declared here
 int n, k, w, h, N, o, R,
        ^
park.cpp:135:11: error: redefinition of 'int w'
 int n, k, w, h, N, o, R,
           ^
park.cpp:27:11: note: 'int w' previously declared here
 int n, k, w, h, N, o, R,
           ^
park.cpp:135:14: error: redefinition of 'int h'
 int n, k, w, h, N, o, R,
              ^
park.cpp:27:14: note: 'int h' previously declared here
 int n, k, w, h, N, o, R,
              ^
park.cpp:135:17: error: redefinition of 'int N'
 int n, k, w, h, N, o, R,
                 ^
park.cpp:27:17: note: 'int N' previously declared here
 int n, k, w, h, N, o, R,
                 ^
park.cpp:135:20: error: redefinition of 'int o'
 int n, k, w, h, N, o, R,
                    ^
park.cpp:27:20: note: 'int o' previously declared here
 int n, k, w, h, N, o, R,
                    ^
park.cpp:135:23: error: redefinition of 'int R'
 int n, k, w, h, N, o, R,
                       ^
park.cpp:27:23: note: 'int R' previously declared here
 int n, k, w, h, N, o, R,
                       ^
park.cpp:136:11: error: redefinition of 'int first [2005]'
     x[2005], y[2005], r[2005], d[2005][4], dis[2005][2005];
           ^
park.cpp:6:11: note: 'int first [2005]' previously declared here
 #define x first
           ^
park.cpp:28:5: note: in expansion of macro 'x'
     x[2005], y[2005], r[2005], d[2005][4], dis[2005][2005];
     ^
park.cpp:136:20: error: redefinition of 'int second [2005]'
     x[2005], y[2005], r[2005], d[2005][4], dis[2005][2005];
                    ^
park.cpp:7:11: note: 'int second [2005]' previously declared here
 #define y second
           ^
park.cpp:28:14: note: in expansion of macro 'y'
     x[2005], y[2005], r[2005], d[2005][4], dis[2005][2005];
              ^
park.cpp:136:29: error: redefinition of 'int r [2005]'
     x[2005], y[2005], r[2005], d[2005][4], dis[2005][2005];
                             ^
park.cpp:28:23: note: 'int r [2005]' previously declared here
     x[2005], y[2005], r[2005], d[2005][4], dis[2005][2005];
                       ^
park.cpp:136:41: error: redefinition of 'int d [2005][4]'
     x[2005], y[2005], r[2005], d[2005][4], dis[2005][2005];
                                         ^
park.cpp:28:32: note: 'int d [2005][4]' previously declared here
     x[2005], y[2005], r[2005], d[2005][4], dis[2005][2005];
                                ^
park.cpp:136:58: error: redefinition of 'int dis [2005][2005]'
     x[2005], y[2005], r[2005], d[2005][4], dis[2005][2005];
                                                          ^
park.cpp:28:44: note: 'int dis [2005][2005]' previously declared here
     x[2005], y[2005], r[2005], d[2005][4], dis[2005][2005];
                                            ^
park.cpp:137:13: error: redefinition of 'int ans [4][4]'
 int ans[4][4], D;
             ^
park.cpp:29:5: note: 'int ans [4][4]' previously declared here
 int ans[4][4], D;
     ^
park.cpp:137:16: error: redefinition of 'int D'
 int ans[4][4], D;
                ^
park.cpp:29:16: note: 'int D' previously declared here
 int ans[4][4], D;
                ^
park.cpp:138:9: error: redefinition of 'std::priority_queue<std::pair<int, int> > q'
 pq<pii> q;
         ^
park.cpp:30:9: note: 'std::priority_queue<std::pair<int, int> > q' previously declared here
 pq<pii> q;
         ^
park.cpp: In function 'void dijk(int)':
park.cpp:139:6: error: redefinition of 'void dijk(int)'
 void dijk(int O){
      ^
park.cpp:31:6: note: 'void dijk(int)' previously defined here
 void dijk(int O){
      ^
park.cpp: In function 'int main()':
park.cpp:156:5: error: redefinition of 'int main()'
 int main(){
     ^
park.cpp:48:5: note: 'int main()' previously defined here
 int main(){
     ^
park.cpp:184:70: warning: operation on 'ans[1][2]' may be undefined [-Wsequence-point]
             ans[1][2]=ans[1][2]=min(ans[1][2], max(d[l][0], d[l][2]));
                                                                      ^
park.cpp: In function 'int main()':
park.cpp:50:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i%i%i%i", &n, &k, &w, &h);
                                      ^
park.cpp:52:45: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i%i%i", &x[l], &y[l], &r[l]);
                                             ^
park.cpp:88:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i%i", &R, &o);
                              ^
park.cpp: In function 'int main()':
park.cpp:158:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i%i%i%i", &n, &k, &w, &h);
                                      ^
park.cpp:160:45: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i%i%i", &x[l], &y[l], &r[l]);
                                             ^
park.cpp:196:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i%i", &R, &o);
                              ^