QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#133825#4942. Robust DefenseSolitaryDreamRE 0ms0kbC++204.8kb2023-08-02 14:51:422023-08-02 14:51:44

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-02 14:51:44]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-08-02 14:51:42]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define int long long

using tii=tuple<int,int,int>;

const int N=511,M=998244353;

int qpow(int a,int b)
{
    int ret=1;
    while(b)
    {
        if(b&1)
            ret=1ll*ret*a%M;
        b>>=1;
        a=1ll*a*a%M;
    }
    return ret;
}

int n,m,S;

int f[N][6],val[N][6];

struct P{
    int x,y;
}a[N],b[N];

P operator +(const P &a,const P &b)
{
    return {a.x+b.x,a.y+b.y};
}

P operator -(const P &a,const P &b)
{
    return {a.x-b.x,a.y-b.y};
}

int operator *(const P &a,const P &b)
{
    return a.x*b.y-a.y*b.x;
}
int operator ^(const P &a,const P &b)
{
    return a.x*b.x+a.y*b.y;
}
int sgn(const P &a)
{
    if(a.x!=0)
        return a.x>0?-1:1;
    assert(a.y!=0);
    return a.y>0?-1:1;
}

bool operator <(const P &a,const P &b)
{
    if(sgn(a)!=sgn(b))
        return sgn(a)<sgn(b);
    return a*b>0;
}

vector<tii>E;

int ty(const P &a)
{
    if(a.x>0)
        return 1;
    if(a.x<0)
        return 3;
    if(a.y>0)
        return 2;
    if(a.y<0)
        return 4;
    assert(0);
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m>>S;
    S=S*qpow(100,M-2)%M;
    for(int i=1;i<=n;i++)
        cin>>a[i].x>>a[i].y;
    for(int i=1;i<=m;i++)
        cin>>b[i].x>>b[i].y;
    sort(b+1,b+m+1,[&](const P &a,const P &b){
        return a.x<b.x||(a.x==b.x&&a.y<b.y);
    });
    for(int i=1;i<=m;i++)
        for(int j=1;j<=m;j++)
        {
            if(i==j)
                continue;
            P v=b[j]-b[i];
            bool ok=1;
            for(int k=1;k<=n;k++)
            {
                if(v*(a[k]-b[i])<0)
                    ok=0;
                if(v*(a[k]-b[i])==0&&((v^(a[k]-b[i]))<0))
                    ok=0;
            }
            if(!ok)
                continue;
            int p=1;
            if(b[i].x!=b[j].x)
            {
                int lx=b[i].x,rx=b[j].x;
                if(lx<=rx)
                    rx--;
                else
                    rx++,swap(lx,rx);
                for(int k=1;k<=m;k++)
                {
                    if(k==i||k==j)
                        continue;
                    if(b[k].x<lx||b[k].x>rx)
                        continue;
                    if(v*(b[k]-b[i])>=0)
                        continue;
                    p=p*(M+1-S)%M;
                }
            }
            else
            {
                int ly=b[i].y,ry=b[j].y;
                if(ly<=ry)
                    ry--;
                else
                    ry++,swap(ly,ry);
                for(int k=1;k<=m;k++)
                {
                    if(k==i||k==j)
                        continue;
                    if(b[k].y<ly||b[k].y>ry)
                        continue;
                    if(v*(b[k]-b[i])>=0)
                        continue;
                    p=p*(M+1-S)%M;
                }

            }
            E.push_back({i,j,p});
        }
        sort(E.begin(),E.end(), [&](const tii &x,const tii &y) {
        auto [ai,aj,ap]=x;
        auto [bi,bj,bp]=y;
        auto da=b[aj]-b[ai],db=b[bj]-b[bi];
        if(da<db||db<da)
            return da<db;
        if(sgn(da)<0)
            return aj>bj;
        else
            return aj<bj;
    });
    for(int i=1;i<=m;i++)
    {
        for(int j=0;j<5;j++)
            val[i][j]=1;
        for(int j=1;j<=m;j++)
        {
            if(i==j)
                continue;
            if(b[j].x<b[i].x&&b[j].y<=b[i].y)
                val[i][0]=(val[i][0]*(M+1-S))%M;
            if(b[j].x>=b[i].x&&b[j].y<b[i].y)
                val[i][1]=(val[i][1]*(M+1-S))%M;
            if(b[j].x>b[i].x&&b[j].y>=b[i].y)
                val[i][2]=(val[i][2]*(M+1-S))%M;
            if(b[j].x<=b[i].x&&b[j].y>b[i].y)
                val[i][3]=(val[i][3]*(M+1-S))%M;
        }
    }
    int ans=0;
    for(int i=1;i<=m;i++)
    {
        memset(f,0,sizeof(f));
        f[i][0]=1;
        // cerr<<endl;
        int mx=0;
        for(auto [u,v,p]:E)
        {
            if(u<i||v<i)
                continue;
            int r=ty(b[v]-b[u]);
            assert(r>=mx);
            mx=r;
            // cerr<<r<<endl;
            for(int k=0;k<=r;k++)
            {
                int coe=1;
                for(int t=k;t<r;t++)
                    coe=coe*val[u][t]%M;
                f[v][r]=(f[v][r]+f[u][k]%M*coe%M*p%M*S%M)%M;
            }
            // f[v]=(f[v]+f[u]*p%M*S)%M;
            // f[v]=(f[v]+f[u]%M)%M;
        }
        // cerr<<b[i].x<<" "<<b[i].y<<" "<<f[i]<<endl;
        assert(!f[i][3]&&!f[i][4]);
        for(int j=1;j<5;j++)
            ans=(ans+f[i][j])%M;
    }
    cout<<ans<<endl;
}
/*
1 8 50
1 1
0 0
0 1
0 2
1 0
1 2
2 0
2 1
2 2
*/

詳細信息

Test #1:

score: 0
Dangerous Syscalls

input:

1 4 50
0 0
-1 0
3 0
0 1
2 -1

output:


result: