제출 #106133

#제출 시각아이디문제언어결과실행 시간메모리
106133eriksuenderhaufPark (BOI16_park)C++11
100 / 100
476 ms41584 KiB
//#pragma GCC optimize("O3") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define enl printf("\n") #define case(t) printf("Case #%d: ", (t)) #define ni(n) scanf("%d", &(n)) #define nl(n) scanf("%lld", &(n)) #define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i]) #define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i]) #define pri(n) printf("%d\n", (n)) #define prl(n) printf("%lld\n", (n)) #define mem(a,v) memset((a),(v),sizeof(a)) #define pii pair<int, int> #define pil pair<int, long long> #define pll pair<long long, long long> #define vii vector<pii> #define vil vector<pil> #define vll vector<pll> #define vi vector<int> #define vl vector<long long> #define pb push_back #define mp make_pair #define fi first #define se second using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef cc_hash_table<int,int,hash<int>> ht; typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset; const double pi = acos(-1); const int MOD = 1e9 + 7; const int INF = 1e9 + 7; const int MAXN = 2e3 + 5; const double eps = 1e-9; int adj[MAXN][MAXN], ans[4][4], x[MAXN], y[MAXN], r[MAXN], par[MAXN]; int mx[MAXN][MAXN]; vi adj2[MAXN]; vector<pair<int,pii>> edg; int qry(int x) { return x == par[x] ? x : par[x] = qry(par[x]); } void join(int u, int v) { u = qry(u), v = qry(v); par[u] = v; } void dfs(int u, int p, int root, int val) { mx[root][u] = val; for (int v: adj2[u]) if (v != p) dfs(v, u, root, max(val, adj[u][v])); } int main() { memset(adj,0x3f,sizeof adj); int n, m, w, h; scanf("%d %d %d %d", &n, &m, &w, &h); for (int j = n; j <= n + 4; j++) { par[j] = j; for (int i = n; i < j; i++) edg.pb({0x3fffffff, {i, j}}); } for (int i = 0; i < n; i++) { par[i] = i; scanf("%d %d %d", &x[i], &y[i], &r[i]); for (int j = 0; j < i; j++) { adj[i][j] = adj[j][i] = (int) floor((hypot(x[i]-x[j],y[i]-y[j])-r[i]-r[j])/2.+eps); edg.pb({adj[i][j], {i, j}}); } adj[i][n+0]=adj[n+0][i]=(y[i]-r[i])/2; adj[i][n+1]=adj[n+1][i]=(x[i]-r[i])/2; adj[i][n+2]=adj[n+2][i]=(w-x[i]-r[i])/2; adj[i][n+3]=adj[n+3][i]=(h-y[i]-r[i])/2; for (int j = 0; j < 4; j++) edg.pb({adj[i][n+j], {i, n+j}}); } sort(edg.begin(), edg.end()); for (int i = 0; i < edg.size(); i++) { int w = edg[i].fi, u, v; tie(u, v) = edg[i].se; if (qry(u) != qry(v)) adj2[u].pb(v), adj2[v].pb(u); join(u, v); } for (int i = n; i < n + 4; i++) { dfs(i, -1, i, 0); ans[i-n][i-n]=0x3fffffff; } ans[0][1]=ans[1][0]=min(mx[n][n+1],min(mx[n][n+2],mx[n][n+3])); ans[0][2]=ans[2][0]=min(min(mx[n][n+1],mx[n][n+3]),min(mx[n+2][n+1],mx[n+2][n+3])); ans[0][3]=ans[3][0]=min(mx[n+1][n],min(mx[n+1][n+2],mx[n+1][n+3])); ans[1][2]=ans[2][1]=min(mx[n+2][n],min(mx[n+2][n+1],mx[n+2][n+3])); ans[1][3]=ans[3][1]=min(min(mx[n][n+2],mx[n][n+3]),min(mx[n+1][n+2],mx[n+1][n+3])); ans[2][3]=ans[3][2]=min(mx[n+3][n],min(mx[n+3][n+1],mx[n+3][n+2])); for (int i = 0; i < m; i++) { int r, e; scanf("%d %d", &r, &e); for (int j = 0; j < 4; j++) if (r <= ans[e-1][j]) printf("%d", j+1); printf("\n"); } }

컴파일 시 표준 에러 (stderr) 메시지

park.cpp: In function 'int main()':
park.cpp:75:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < edg.size(); i++) {
                     ~~^~~~~~~~~~~~
park.cpp:76:10: warning: unused variable 'w' [-Wunused-variable]
      int w = edg[i].fi, u, v;
          ^
park.cpp:54:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d %d", &n, &m, &w, &h);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
park.cpp:62:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
      scanf("%d %d %d", &x[i], &y[i], &r[i]);
      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
park.cpp:94:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
      scanf("%d %d", &r, &e);
      ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...