QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#602278#7029. Xu Xiake in Henan Provinceucup-team5071#WA 0ms3776kbC++203.8kb2024-09-30 22:34:232024-09-30 22:34:25

Judging History

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

  • [2024-09-30 22:34:25]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3776kb
  • [2024-09-30 22:34:23]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
    int n,q;
    cin>>n>>q;
    ll ans=0;
    if(n==1){
        int z;cin>>z>>z;
        while(q--){
            char c;cin>>c;
            if(c=='!')cout<<"0\n";
            else if(c=='?'){
                int x;cin>>x;
                cout<<"1 1\n";
            }
            else {
                int x;cin>>x;
            }
        }
        return;
    }
    vector<int> x(n+1),y(n+1);
    vector<int> up(n+1),down(n+1),left(n+1),right(n+1);
    vector<int> px(n+1);//the x of point on y
    vector<int> py(n+1);//the y of point on x
    int lu=0,ld=0,ru=0,rd=0;
    int l1=1,l2=n,t1=1,t2=n;//actually bound
    int x1=1,x2=n,y1=1,y2=n;//virtual bound
    for(int i=1;i<=n;i++){
        cin>>x[i]>>y[i];
        py[x[i]]=y[i];
        px[y[i]]=x[i];
        if(x[i]==1&&y[i]==1)lu++;
        else if(x[i]==1&&y[i]==n)ru++;
        else if(x[i]==n&&y[i]==1)ld++;
        else if(x[i]==n&&y[i]==n)rd++;
        else if(x[i]==1)up[y[i]]++;
        else if(x[i]==n)down[y[i]]++;
        else if(y[i]==1)left[x[i]]++;
        else if(y[i]==n)right[x[i]]++;
    }
    auto actual_point = [&](int x,int y){
        return make_pair(x-x1+l1,y-y1+t1);
    };
    auto merge = [&](int &x,int y){//calcu ans when merge
        ans+=(ll)x*y; 
        x+=y;
    };
    while(q--){
        char c;cin>>c;
        if(c=='!'){cout<<ans<<"\n";continue;}
        if(c=='?'){
            int i;cin>>i;
            int ax,ay;
            if(x[i]<=x1&&y[i]<=y1)tie(ax,ay)=actual_point(x1,y1);
            else if(x[i]<=x1&&y[i]>=y2)tie(ax,ay)=actual_point(x1,y2);
            else if(x[i]>=x2&&y[i]<=y1)tie(ax,ay)=actual_point(x2,y1);
            else if(x[i]>=x2&&y[i]>=y2)tie(ax,ay)=actual_point(x2,y2);
            else if(x[i]<=x1)tie(ax,ay)=actual_point(x1,y[i]);
            else if(x[i]>=x2)tie(ax,ay)=actual_point(x2,y[i]);
            else if(y[i]<=y1)tie(ax,ay)=actual_point(x[i],y1);
            else if(y[i]>=y2)tie(ax,ay)=actual_point(x[i],y2);
            else tie(ax,ay)=actual_point(x[i],y[i]);
            cout<<ax<<" "<<ay<<"\n";
            continue;
        }
        int k;cin>>k;
        {//move the actual bound to the map bound
            int d=0;
            if(c=='L'){d=min(k,t1-1);k-=d;t1-=d;t2-=d;}
            if(c=='R'){d=min(k,n-t2);k-=d;t1+=d;t2+=d;}
            if(c=='U'){d=min(k,l1-1);k-=d;l1-=d;l1-=d;}
            if(c=='D'){d=min(k,n-l2);k-=d;l2+=d;l2+=d;}
            if(d==0)continue;
        }
        if((c=='L'||c=='R')&&y1==y2){//just line move
            continue;
        }
        if((c=='U'||c=='D')&&x1==x2){//just line move
            continue;
        }
        while(k--){
            if(c=='L'){
                if(y1+1<y2){//not merge
                    if(x1==x2){
                        merge(lu,up[y1+1]);
                    }
                    else{
                        if(x1<px[y1]&&px[y1]<x2){
                            merge(left[px[y1]],1);
                            left[px[y1]]++;
                        }
                        merge(lu,up[y1+1]);
                        merge(ld,down[y1+1]);
                    }
                }
                else{//merge
                    if(x1==x2){
                        merge(lu,ru);
                    }
                    else{
                        merge(lu,ru);
                        merge(ld,rd);
                        for(int i=x1+1;i<x2;i++)merge(left[i],right[i]);
                    }
                }
                y1++;t2--;
            }
            if(c=='R'){

            }
            if(c=='U'){

            }
            if(c=='D'){

            }
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;cin>>T;while(T--)solve();
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3776kb

input:

5
0 0 0 0
0 0 0 1
1 1 0 0
2 1 1 0
1 2 3 4

output:


result:

wrong answer 1st lines differ - expected: 'Typically Otaku', found: ''