QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#724196#1958. Grid TriangleAMATSUKAZE#AC ✓1ms3860kbC++203.1kb2024-11-08 10:42:242024-11-08 10:42:26

Judging History

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

  • [2024-11-08 10:42:26]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3860kb
  • [2024-11-08 10:42:24]
  • 提交

answer

#pragma GCC optimize("O3,Ofast,unroll-loops")

#include<bits/stdc++.h>
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define all(v) begin(v),end(v)
using namespace std;
using ll = long long;
using vl=vector<ll>;
using vs=vector<string>;
bool chmin(auto &a, auto b){ return a > b ? a = b, 1 : 0; }
bool chmax(auto &a, auto b){ return a < b ? a = b, 1 : 0; }

bool check(vl a,vl b){
    for(auto &x:a) x=abs(x);
    for(auto &x:b) x=abs(x);
    sort(all(a));
    sort(all(b));
    return a==b&&0<a[0]&&a[0]<a[1]&&a[1]<a[2];
}

ll f(ll A,ll B,ll C){
    ll rs=0;
    rep(x,-A,A+1)rep(y,-B,B+1)rep(z,-C,C+1){
        vl b=vl{x,y,z};
        sort(all(b));
        do{
            rep(S,0,8){
                vl c=b;
                rep(k,0,3)if(S&1<<k) c[k]*=-1;
                ll u=c[0],v=c[1],w=c[2];
                vl a;
                a.emplace_back(abs(x-u));
                a.emplace_back(abs(y-v));
                a.emplace_back(abs(z-w));
                if(abs(u)<=A&&abs(v)<=B&&abs(w)<=C&&check(a,b)) rs++;
            }
        }while(next_permutation(all(b)));
    }
    return rs>>1;
}

ll g(ll A,ll B,ll C){
    ll rs=0;
    rep(i,0,3){
        rep(y,1,A+1)rep(x,1,y){
            if(x+y<=min(B,C)){
                rs++;
//                cout<<x<<' '<<y<<' '<<A<<' '<<min(B,C)<<endl;
            }
        }
        swap(A,B);
        swap(B,C);
    }
    return rs<<4;
}

ll calc_sum(ll n,ll d){
    return (n+d)/d*(n+n%d)/2;
}

ll calc(ll A,ll B){
    if(A<0||B<0) return 0;
    ll rs;
    if(B>=2*A) rs=calc_sum(A+1,1);
    else if(B>=A) rs=calc_sum(2*A-B+1,2)+(3*A-B+3)*(B-A)/2;
    else rs=calc_sum(B+1,2);
//    cout<<A<<' '<<B<<' '<<rs<<endl;
    return rs;
}

ll h(ll A,ll B,ll C){
    ll rs=0;
    rep(i,0,3){
        rs+=calc(A-2,min(B,C)-3);
        swap(A,B);
        swap(B,C);
    }
    return rs<<4;
}

int main(){
    cin.tie(0)->sync_with_stdio(0);

    ll A,B,C;
    cin>>A>>B>>C;
    cout<<h(A,B,C)<<endl;

    // g(4,6,6);
    // h(4,6,6);

    // ll n;
    // cin>>n;
    // rep(A,1,n)rep(B,A,n)rep(C,B,n){
    //     cout<<A<<' '<<B<<' '<<C<<endl;
    //     ll u=h(A,B,C);
    //     ll v=g(A,B,C);
    //     if(u!=v) cout<<u<<' '<<v<<endl;
    //     assert(u==v);
    // }

    // cout<<g(3,3,3)<<endl;
    // cout<<g(3,3,2)<<endl;
    // cout<<g(3,2,2)<<endl;

    // return 0;

    // ll n;
    // cin>>n;
    // rep(x,0,n+1)rep(y,x,n+1)rep(z,y,n+1){
    //     vl b=vl{x,y,z};
    //     do{
    //         rep(S,0,8){
    //             vl c=b;
    //             rep(k,0,3)if(S&1<<k) c[k]*=-1;
    //             vl a;
    //             a.emplace_back(abs(x-c[0]));
    //             a.emplace_back(abs(y-c[1]));
    //             a.emplace_back(abs(z-c[2]));
    //             sort(all(a));
    //             if(a==vl{x,y,z}){
    //                 cout<<x<<' '<<y<<' '<<z<<' '<<c[0]<<' '<<c[1]<<' '<<c[2]<<endl;
    //                 assert(x+y==z);
    //             }
    //         }
    //     }while(next_permutation(all(b)));
    // }
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3552kb

input:

1 1 4

output:

0

result:

ok single line: '0'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

1 1 5

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

1 2 6

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3504kb

input:

1 2 7

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

2 2 8

output:

0

result:

ok single line: '0'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

2 3 9

output:

16

result:

ok single line: '16'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3500kb

input:

2 3 10

output:

16

result:

ok single line: '16'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

2 3 11

output:

16

result:

ok single line: '16'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

3 4 12

output:

64

result:

ok single line: '64'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

3 4 13

output:

64

result:

ok single line: '64'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

3 4 14

output:

64

result:

ok single line: '64'

Test #12:

score: 0
Accepted
time: 1ms
memory: 3784kb

input:

3 5 15

output:

80

result:

ok single line: '80'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

10000000 10000000 10000000

output:

1199999760000000

result:

ok single line: '1199999760000000'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

7663341 2799917 6434354

output:

125432496112224

result:

ok single line: '125432496112224'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

5847310 6503054 3563307

output:

196607948002960

result:

ok single line: '196607948002960'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

3131008 7950384 757301

output:

9176058698400

result:

ok single line: '9176058698400'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

9570661 9593872 9917084

output:

1100945395924880

result:

ok single line: '1100945395924880'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

3510873 8095808 2299177

output:

79848923155584

result:

ok single line: '79848923155584'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

7476400 3286922 144073

output:

332109011520

result:

ok single line: '332109011520'

Test #20:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

2528777 8583320 3053921

output:

86257168366272

result:

ok single line: '86257168366272'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

756027 9877774 6224461

output:

9145211051024

result:

ok single line: '9145211051024'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

1799348 1545770 5903860

output:

31551400528464

result:

ok single line: '31551400528464'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

2866047 8448813 9201454

output:

131427537714224

result:

ok single line: '131427537714224'

Test #24:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

3253 19822 15760

output:

169234080

result:

ok single line: '169234080'

Test #25:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

18973 6799 2004

output:

64208160

result:

ok single line: '64208160'

Test #26:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

1607 25903 7685

output:

41280624

result:

ok single line: '41280624'

Test #27:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

8763 27091 27201

output:

1228432400

result:

ok single line: '1228432400'

Test #28:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

3275 1018 17315

output:

16556752

result:

ok single line: '16556752'

Test #29:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

31480 24767 5816

output:

541074112

result:

ok single line: '541074112'

Test #30:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

22046 8058 12456

output:

985126032

result:

ok single line: '985126032'

Test #31:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

10321 22446 10938

output:

1327450496

result:

ok single line: '1327450496'

Test #32:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

14930 18763 2124

output:

72131040

result:

ok single line: '72131040'

Test #33:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

18366 14707 1959

output:

61355888

result:

ok single line: '61355888'

Test #34:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

4 4 4

output:

96

result:

ok single line: '96'

Test #35:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

5 5 5

output:

192

result:

ok single line: '192'

Test #36:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

6 6 6

output:

288

result:

ok single line: '288'

Test #37:

score: 0
Accepted
time: 0ms
memory: 3500kb

input:

7 7 7

output:

432

result:

ok single line: '432'

Test #38:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

8 8 8

output:

576

result:

ok single line: '576'

Test #39:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

9 9 9

output:

768

result:

ok single line: '768'

Test #40:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

10 10 10

output:

960

result:

ok single line: '960'