제출 #474036

#제출 시각아이디문제언어결과실행 시간메모리
474036idasPark (BOI16_park)C++11
27 / 100
904 ms66448 KiB
#include <bits/stdc++.h> #define FOR(i, begin, end) for(int i = (begin); i < (end); i++) #define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr) #define F first #define S second #define PB push_back #define MP make_pair #define SZ(x) ((int)((x).size())) #define LE(vec) vec[vec.size()-1] #define TSTS int t; cin >> t; while(t--)solve() const int INF = 1e9; const long long LINF = 1e18; const long double PI = asin(1)*2; const int MOD = 1e9+7; using namespace std; typedef pair<int, int> pii; typedef vector<int> vi; typedef map<int, int> mii; typedef long long ll; typedef long double ld; void setIO() { FAST_IO; } void setIO (string s) { setIO(); freopen((s+".in").c_str(),"r",stdin); freopen((s+".out").c_str(),"w",stdout); } const int N=5e3+10, M=5e5+10; int n, m, w, h, par[N]; set<int> ans[N]; vector<pair<int, pii>> vis; int fnd(int u) { return par[u]=par[u]==u?u:fnd(par[u]); } bool same(int a, int b) { return fnd(a)==fnd(b); } void mrg(int a, int b) { a=fnd(a); b=fnd(b); if(a==b) return; par[a]=b; } void out(int r, int e, int idx) { bool con[5][5]; FOR(i, 0, 5) FOR(j, 0, 5) con[i][j]=true; if(same(n+3, n+1)){ con[4][1]=false; con[4][2]=false; con[3][1]=false; con[3][2]=false; } if(same(n, n+2)){ con[1][3]=false; con[1][2]=false; con[4][2]=false; con[4][3]=false; } //1 if(same(n+3, n+2)){ con[1][2]=false; con[1][3]=false; con[1][4]=false; } //2 if(same(n+1, n+2)){ con[2][1]=false; con[2][3]=false; con[2][4]=false; } //3 if(same(n, n+1)){ con[3][1]=false; con[3][2]=false; con[3][4]=false; } //4 if(same(n, n+3)){ con[4][1]=false; con[4][2]=false; con[4][3]=false; } FOR(i, 0, 5) { FOR(j, 0, 5) { con[i][j]=(con[i][j]&&con[j][i]); } } FOR(i, 1, 5) { if(con[e][i]) ans[idx].insert(i); } } int main() { setIO(); cin >> n >> m >> w >> h; vector<pair<int, pii>> in; FOR(i, 0, n) { par[i]=i; int x, y, r; cin >> x >> y >> r; in.PB({r, {x, y}}); } FOR(i, n, n+4) par[i]=i; FOR(i, 0, m) { int r, e; cin >> r >> e; vis.PB({r, {e, i}}); } sort(vis.begin(), vis.end()); priority_queue<pair<ld, pii>, vector<pair<ld, pii>>, greater<pair<ld, pii>>> pth; FOR(i, 0, (int)in.size()) { FOR(j, i+1, (int)in.size()) { ll x=in[i].S.F, y=in[i].S.S, r=in[i].F, z=in[j].S.F, ww=in[j].S.S, l=in[j].F; ll dist=(x-z)*(x-z)+(y-ww)*(y-ww); ld b=1; ld d=sqrt(b*dist); d-=ld(r+l); pth.push({d, {i, j}}); } ll x=in[i].S.F, y=in[i].S.S, r=in[i].F; pth.push({(h-y-r), {i, n}}); pth.push({(w-x-r), {i, n+1}}); pth.push({(y-r), {i, n+2}}); pth.push({(x-r), {i, n+3}}); } for(auto it : vis){ int r=it.F, e=it.S.F, idx=it.S.S; while(!pth.empty() && pth.top().F<2*r){ mrg(pth.top().S.F, pth.top().S.S); pth.pop(); } out(r, e, idx); } FOR(i, 0, m) { for(auto x : ans[i]){ cout << x; } cout << '\n'; } }

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

park.cpp: In function 'void setIO(std::string)':
park.cpp:32:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |   freopen((s+".in").c_str(),"r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
park.cpp:33:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |   freopen((s+".out").c_str(),"w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...