QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#228305#7583. FarawayGiga_CronosAC ✓751ms3616kbC++203.0kb2023-10-28 13:19:142023-10-28 13:19:14

Judging History

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

  • [2023-10-28 13:19:14]
  • 评测
  • 测评结果:AC
  • 用时:751ms
  • 内存:3616kb
  • [2023-10-28 13:19:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mid ((L+R)/2)
#define pb push_back
#define fs first 
#define sc second 
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size())

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
const int MAXN=2000;



int n,k,m;
int Calc(int x,int L,int R){
    int d=L/60*60 +x;
    if(d>=L){
        d-=60;
    }
    int e=R/60*60+x;
    if(e>=R){
        e-=60;
    }
    return (e-d)/60;
}

bool Can(int x,int y,pii Sig,int c,int m){
        x%=m;
        y%=m;
        x=(x*Sig.fs+m)%m;
        y=(y*Sig.sc+m)%m;
        return (x+y)%m==c%m;
}

int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int tc=1;
    cin>>tc;
    while(tc--){
          cin>>n>>m;
          vector<pair<pii,pii>> V;
          vi CoordX;
          vi CoordY;  
          for(int i=0;i<n;i++){
            int a,b,c,d;
            cin>>a>>b>>c>>d;
            CoordX.pb(a);
            CoordY.pb(b);
            V.pb({{a,b},{c,d}});
          }  
          CoordX.pb(0);
          CoordX.pb(m+1);
          CoordY.pb(0);
          CoordY.pb(m+1);
          sort(all(CoordX));
          CoordX.resize(unique(all(CoordX))-CoordX.begin());
          sort(all(CoordY));
          CoordY.resize(unique(all(CoordY))-CoordY.begin());

        int ans=0;
          for(int i=0;i<sz(CoordX)-1;i++){
            int Lx=CoordX[i],Rx=CoordX[i+1];
            for(int j=0;j<sz(CoordY)-1;j++){
                int Ly=CoordY[j],Ry=CoordY[j+1];
                vector<pair<pii,pii>> Tup;
                for(int h=0;h<n;h++){
                    pii Sig;
                    int c=V[h].sc.sc;
                    int mo=V[h].sc.fs;
                    if(V[h].fs.fs>Lx){
                       Sig.fs=-1;    
                       c=(c-V[h].fs.fs%mo+mo)%mo; 
                    }else{
                        Sig.fs=1;
                       c=(c+V[h].fs.fs%mo)%mo; 
                    }
                    if(V[h].fs.sc>Ly){
                       Sig.sc=-1;  
                        c=c-V[h].fs.sc%mo+mo; 
                    }else{
                        Sig.sc=1;
                       c+=V[h].fs.sc%mo;   
                    }
                    c%=mo;
                    c+=2*mo;
                    c%=mo;
                    Tup.pb({Sig,{c,mo}});
                    
                }

                for(int x=0;x<60;x++){
                    for(int y=0;y<60;y++){
                        bool can=true;
                        for(int h=0;h<n;h++){
                            can&=Can(x,y,Tup[h].fs,Tup[h].sc.fs,Tup[h].sc.sc); 
                        }    
                        if(can){
                           
                            ans+=Calc(x,Lx,Rx)*Calc(y,Ly,Ry);
                        }
                    }
                }        

            }
          }
          cout<<ans<<'\n';

    }



}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3616kb

input:

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

output:

10
0

result:

ok 2 number(s): "10 0"

Test #2:

score: 0
Accepted
time: 751ms
memory: 3532kb

input:

10
10 950006
879210 618398 2 0
413993 805537 5 0
614389 782151 5 4
616385 454674 4 2
6020 332147 5 0
77932 43110 4 1
143614 196643 4 0
937161 934707 4 1
318567 789911 4 0
194658 555381 5 3
10 967857178
8983267 44864625 3 2
141087113 359274718 2 1
909006720 262061158 3 0
840340929 715591525 3 2
76531...

output:

0
0
0
116256265
43298776834
1839945977784
820599567890959
19922821864719464
50544306663055
64150016306836

result:

ok 10 numbers