QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#884219 | #2599. Anti-stress | staring | WA | 86ms | 13268kb | C++14 | 3.7kb | 2025-02-05 22:16:39 | 2025-02-05 22:16:40 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
namespace staring
{
typedef long long LL;
typedef vector<int> VEC;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define fir first
#define sec second
#define FOR(i,a,b) for(int i=(a),__i=(b);i<=__i;i++)
#define ROF(i,a,b) for(int i=(a),__i=(b);i>=__i;i--)
template<typename TYPE>
TYPE gmax(TYPE &x,const TYPE y){return x<y?x=y:x;}
template<typename TYPE>
TYPE gmin(TYPE &x,const TYPE y){return y<x?x=y:x;}
static constexpr int SIZE=1<<20;
static char buffin[SIZE]{},*pin1{},*pin2{};
static char buffout[SIZE]{},*pout{buffout};
#define GETC() (pin1==pin2&&(pin2=(pin1=buffin)+fread(buffin,1,SIZE,stdin),pin1==pin2)?EOF:*pin1++)
#define PUTC(c) (pout-buffout==SIZE&&(fwrite(buffout,1,SIZE,stdout),pout=buffout),*pout++=c)
template<typename TYPE>
void read(TYPE &x)
{
static int signf{0},chin{0};
x=signf=0,chin=GETC();
while(chin<'0'||chin>'9')signf|=chin=='-',chin=GETC();
while(chin>='0'&&chin<='9')x=(x<<3)+(x<<1)+(chin^48),chin=GETC();
if(signf)x=-x;
}
template<typename TYPE>
void write(TYPE x,char ch=' ')
{
static char stack[64]{},top{0};
!x&&PUTC('0'),x<0&&(x=-x,PUTC('-'));
while(x)stack[top++]=x%10|48,x/=10;
while(top)PUTC(stack[--top]);
if(ch)PUTC(ch);
}
}using namespace staring;
constexpr int N=2e5+5,M=N<<1;
constexpr double EPS=1e-8,PI=acos(-1);
typedef complex<double> point;
int n;
point p[M];
mt19937 seed(time(0));
uniform_real_distribution<double> rnd(0,EPS);
pair<double,int> x[M],y[M];
int signx[M],signy[M];
int success;
int f(double theta)
{
if(success)return 0;
point rotate={cos(theta),sin(theta)};
FOR(i,1,n<<1)
{
point t=p[i]*rotate;
x[i]={t.real(),i},y[i]={t.imag(),i};
}
nth_element(x+1,x+n,x+(n<<1|1));
nth_element(y+1,y+n,y+(n<<1|1));
FOR(i,1,n<<1)signx[x[i].sec]=i>n,signy[y[i].sec]=i>n;
// FOR(i,1,n<<1)
// cerr<<theta<<' '<<i<<' '<<signx[i]<<' '<<signy[i]<<endl;
int cnt=0;
FOR(i,1,n)cnt+=signx[i]&&signy[i];
// signx[i]&&signy[i]&&(cout<<i<<' ');
// cout<<endl;
// cerr<<theta<<' '<<cnt<<' ';
FOR(i,n+1,n<<1)cnt-=!signx[i]&&!signy[i];
// !signx[i]&&!signy[i]&&(cout<<i<<' ');
// cout<<"--------------\n";
// cerr<<cnt<<endl;
if(!cnt)
{
success=1;
int x1=max_element(x+1,x+n+1)->fir,x2=min_element(x+n+1,x+(n<<1|1))->fir;
int y1=max_element(y+1,y+n+1)->fir,y2=min_element(y+n+1,y+(n<<1|1))->fir;
point white={(x1+x2)/2,(y1+y2)/2};white=white/rotate;
printf("%lf %lf\n",white.real(),white.imag());
// cerr<<theta<<' '<<x1<<' '<<x2<<' '<<y1<<' '<<y2<<endl;
// FOR(i,1,n<<1)
// cerr<<i<<' '<<signx[i]<<' '<<signy[i]<<endl;
VEC blue[2][2];
FOR(i,n+1,n<<1)blue[signx[i]][signy[i]].push_back(i);
FOR(i,1,n)
{
printf("%d ",blue[!signx[i]][!signy[i]].back()-n);
blue[!signx[i]][!signy[i]].pop_back();
}
puts("");
}
return cnt;
}
void solve()
{
read(n);
FOR(i,1,n<<1)
{
int a,b;read(a),read(b);
p[i]={a+rnd(seed),b+rnd(seed)};
}
success=0;
double l=0,r=PI/2;
int fl=f(l),fr=f(r);
// cerr<<fl<<' '<<fr<<endl;
while(!success)
{
double mid=(l+r)/2;
int fmid=f(mid);
if(1ll*fmid*fl<0)r=mid,fr=fmid;
else l=mid,fl=fmid;
}
}
int main()
{
int T;read(T);
while(T--)solve();
fwrite(buffout,1,pout-buffout,stdout);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 12380kb
input:
3 3 -2 -2 1 2 -1 3 -2 3 -1 -1 2 -1 2 1 2 -1 0 2 -1 0 0 2 3 2 -2 -1 -3 -1 1 -3
output:
0.000000 0.000000 1 3 2 0.000000 0.000000 2 1 -0.707107 -0.707107 1 2
result:
ok Correct matching.
Test #2:
score: -100
Wrong Answer
time: 86ms
memory: 13268kb
input:
36292 6 -6 10 -9 7 -7 -7 6 6 3 -6 2 -7 8 10 7 7 9 7 -9 9 5 5 -1 1 10 10 0 -4 2 10 -4 -8 9 9 -10 -8 2 4 -2 2 4 0 -9 10 4 4 -8 -6 8 0 7 5 0 -5 5 3 -9 3 7 4 -3 1 3 -9 -8 5 -3 4 1 -7 -1 10 -3 3 -4 2 -1 0 6 -7 8 -6 -8 0 -8 7 3 7 3 8 10 -10 8 -4 -2 0 1 -5 5 7 -6 1 6 -10 3 5 3 -5 4 -2 -3 0 -10 5 -2 -6 3 0 ...
output:
-1.148050 2.771639 5 3 2 6 4 1 2.000000 1.000000 9 8 5 6 3 4 2 1 7 10 -1.000000 1.000000 3 5 4 2 1 -1.000000 4.000000 3 1 2 0.896258 -2.048590 6 4 7 5 1 3 2 -4.000000 0.000000 1 2 3.000000 -3.000000 1 0.000000 0.000000 9 8 5 10 7 2 6 1 3 4 0.000000 -3.000000 3 2 4 1 0.707107 -0.707107 5 3 4...
result:
wrong answer The angle is not obtuse.