Submission #403491

#TimeUsernameProblemLanguageResultExecution timeMemory
403491jamezzz레이저 센서 (KOI16_laser)C++14
0 / 100
1 ms460 KiB
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #include <ext/rope> using namespace __gnu_cxx; typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds; //less_equal for identical elements //#define DEBUG #ifdef DEBUG #define debug(...) printf(__VA_ARGS__); #else #define debug(...) #endif #define sf scanf #define pf printf #define fi first #define se second #define pb emplace_back #define sz(x) (int)x.size() #define mnto(x,y) x=min(x,(__typeof__(x))y) #define mxto(x,y) x=max(x,(__typeof__(x))y) #define INF 1023456789 #define LINF 1023456789123456789 #define all(x) x.begin(), x.end() typedef long long ll; typedef long double ld; typedef pair<int, int> ii; typedef pair<ll, ll> pll; typedef tuple<int, int, int> iii; typedef tuple<int, int, int, int> iiii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<pll> vll; int n,x,y,t,id,pfx[9005]; ii ans[3005]; vector<iiii> v; void dnc(vii vv){ int s; int m=sz(vv); vii a; for(int i=0;i<m;++i){ if(vv[i].fi==0){ s=i;break; } } for(int i=s;i<m;++i)a.pb(vv[i]); for(int i=0;i<s;++i)a.pb(vv[i]); for(int i=0;i<m;++i){ if(i==0)pfx[i]=a[i].fi; else pfx[i]=pfx[i-1]+a[i].fi; } #ifdef DEBUG pf("%d\n",s); for(ii p:a){ pf("%d %d\n",p.fi,p.se); } #endif //DEBUG for(int i=0;i<m;++i){ if(a[i].fi==0||a[(i+1)%m].fi==0)continue; bool pos=true; if(i!=1){ int cnt=pfx[i-1]-pfx[0]; int sz=i-1; pos=pos&&(cnt%2==0&&cnt/2*3==sz); } if(i+1!=m-1){ int cnt=pfx[m-1]-pfx[i+1]; int sz=m-(i+2); pos=pos&&(cnt%2==0&&cnt/2*3==sz); } debug("%d\n",i); if(pos){ debug("done\n"); ans[a[0].se]=ii(a[i].se,a[i+1].se); if(i!=1){ vii vl; for(int x=1;x<i;++x){ vl.pb(a[x]); } dnc(vl); } if(i+1!=m-1){ vii vr; for(int x=i+2;x<m;++x){ vr.pb(a[x]); } dnc(vr); } } } } int main(){ sf("%d",&n); for(int i=0;i<3*n;++i){ sf("%d%d",&x,&y); v.pb(x,y,(i>=n),i); } sort(all(v)); vii tmp; for(int i=0;i<3*n;++i){ tie(x,y,t,id)=v[i]; tmp.pb(t,id); } dnc(tmp); for(int i=0;i<n;++i)pf("%d %d\n",ans[i].fi,ans[i].se); } /* 2 1 0 4 0 2 0 3 0 5 0 6 0 */

Compilation message (stderr)

laser.cpp: In function 'int main()':
laser.cpp:103:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  103 |  sf("%d",&n);
      |    ^
laser.cpp:105:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  105 |   sf("%d%d",&x,&y);
      |     ^
laser.cpp: In function 'void dnc(vii)':
laser.cpp:46:6: warning: 's' may be used uninitialized in this function [-Wmaybe-uninitialized]
   46 |  int s;
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...