QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#34143#1958. Grid TriangleJD-14 京东不会没有脆香米吧(Luotian Huang, Yufan Xiang, Ziji Wang)#AC ✓7ms3800kbC++2.9kb2022-06-05 18:00:222022-06-05 18:00:23

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-06-05 18:00:23]
  • Judged
  • Verdict: AC
  • Time: 7ms
  • Memory: 3800kb
  • [2022-06-05 18:00:22]
  • Submitted

answer

// Skyqwq
#include <bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define mp make_pair

using namespace std;

typedef pair<int, int> PII;
typedef long long LL;

template <typename T> bool chkMax(T &x, T y) { return (y > x) ? x = y, 1 : 0; }
template <typename T> bool chkMin(T &x, T y) { return (y < x) ? x = y, 1 : 0; }

template <typename T> void inline read(T &x) {
    int f = 1; x = 0; char s = getchar();
    while (s < '0' || s > '9') { if (s == '-') f = -1; s = getchar(); }
    while (s <= '9' && s >= '0') x = x * 10 + (s ^ 48), s = getchar();
    x *= f;
}

LL ans;

LL A, B, C;

int c[10];

int d[6];

int t;

LL cnt;

int w[3][3], f[3][3], mb[3], mx[3];

typedef pair<LL, LL> PLL;

typedef pair<PLL, LL> POO;

map<POO, LL> O;


LL inline calc(LL a, LL b, LL c){
	if (O.count(mp(mp(a, b), c))) return O[mp(mp(a, b), c)];
	LL tt = 0;
	for (int i = 1; i <= a; i++) {
		LL lb = i + 1, rb = min(c - i, b);
		if (lb <= rb) tt += rb - lb + 1;
	}
	return O[mp(mp(a, b), c)] = tt;
}

void inline chk() {
	w[1][0] = d[0];
	w[1][1] = d[1];
	w[1][2] = d[2];
	w[2][0] = d[3];
	w[2][1] = d[4];
	w[2][2] = d[5];
	int o = 0;

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < i; j++) {
			bool op = 1;			
			for (int k = 0; k < 3; k++) {
				f[o][k] = abs(w[i][k] - w[j][k]);
				if (f[o][k]) op = 0;
			}
			if (op) return ;
			o++;
		}
	}
	memset(mx, 0, sizeof mx);
	for (int i = 0; i < 3; i++) {
		sort(f[i], f[i] + 3);
		for (int j = 0; j < 3; j++) {
			chkMax(mx[j], abs(w[i][j]));
			if (f[i][j] != mb[j]) return ;
		}
	}

	LL ma = 2e9, mb = 2e9, mc = 2e9;
	for (int i = 0; i < 3; i++) {
		if (mx[i] == 1000) {
			chkMin(mb, i == 0 ? A : (i == 1 ? B : C));
			chkMin(ma, i == 0 ? A : (i == 1 ? B : C));
		} else if (mx[i] == 1001) {
			chkMin(mc, i == 0 ? A : (i == 1 ? B : C));
			chkMin(mb, i == 0 ? A : (i == 1 ? B : C));
			chkMin(ma, i == 0 ? A : (i == 1 ? B : C));
		} else assert(false);
	}

	ans += calc(ma, mb, mc);
	// cout << ma << " " << mb << " " << mc << " " << calc(ma, mb, mc) << " why?\n";
	// for (int i = 0; i < 3; i++) {
	// 	for (int j = 0; j < 3; j++) {
	// 		cout << w[i][j] << ", ";
	// 	}
	// 	cout << endl;
	// }
	// puts("");
}

void dfs(int u) {
	if (u == 6) {
		chk();
		return;
	}
	for (int i = 1; i <= t; i++) {
		d[u] = c[i];
		dfs(u + 1);
	}
}

int main() {
    read(A), read(B), read(C);
    if (A > B) swap(A, B);
    if (A > C) swap(A, C);
    if (B > C) swap(B, C);
    LL L = min(A, min(B, C));
    // 1

    LL zg = 0;
    for (LL i = 1; i <= L; i++) {
    	zg += i - 1;
    	if (i % 2 == 0) zg--;
    }
    cnt = 0;
    t = 0;
    mb[0] = 1;
    mb[1] = 1000;
    mb[2] = 1001;
    c[++t] = 1;
    c[++t] = -1;
    c[++t] = 0;
    c[++t] = 1000;
    c[++t] = -1000;
    c[++t] = 1001;
    c[++t] = -1001;
    dfs(0);
  
    ans /= 2;
    printf("%lld\n", ans);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 3704kb

input:

1 1 4

output:

0

result:

ok single line: '0'

Test #2:

score: 0
Accepted
time: 4ms
memory: 3744kb

input:

1 1 5

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Accepted
time: 4ms
memory: 3720kb

input:

1 2 6

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 2ms
memory: 3584kb

input:

1 2 7

output:

0

result:

ok single line: '0'

Test #5:

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

input:

2 2 8

output:

0

result:

ok single line: '0'

Test #6:

score: 0
Accepted
time: 5ms
memory: 3704kb

input:

2 3 9

output:

16

result:

ok single line: '16'

Test #7:

score: 0
Accepted
time: 2ms
memory: 3672kb

input:

2 3 10

output:

16

result:

ok single line: '16'

Test #8:

score: 0
Accepted
time: 4ms
memory: 3704kb

input:

2 3 11

output:

16

result:

ok single line: '16'

Test #9:

score: 0
Accepted
time: 5ms
memory: 3628kb

input:

3 4 12

output:

64

result:

ok single line: '64'

Test #10:

score: 0
Accepted
time: 2ms
memory: 3712kb

input:

3 4 13

output:

64

result:

ok single line: '64'

Test #11:

score: 0
Accepted
time: 4ms
memory: 3700kb

input:

3 4 14

output:

64

result:

ok single line: '64'

Test #12:

score: 0
Accepted
time: 2ms
memory: 3708kb

input:

3 5 15

output:

80

result:

ok single line: '80'

Test #13:

score: 0
Accepted
time: 7ms
memory: 3704kb

input:

10000000 10000000 10000000

output:

1199999760000000

result:

ok single line: '1199999760000000'

Test #14:

score: 0
Accepted
time: 6ms
memory: 3676kb

input:

7663341 2799917 6434354

output:

125432496112224

result:

ok single line: '125432496112224'

Test #15:

score: 0
Accepted
time: 7ms
memory: 3724kb

input:

5847310 6503054 3563307

output:

196607948002960

result:

ok single line: '196607948002960'

Test #16:

score: 0
Accepted
time: 5ms
memory: 3628kb

input:

3131008 7950384 757301

output:

9176058698400

result:

ok single line: '9176058698400'

Test #17:

score: 0
Accepted
time: 7ms
memory: 3736kb

input:

9570661 9593872 9917084

output:

1100945395924880

result:

ok single line: '1100945395924880'

Test #18:

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

input:

3510873 8095808 2299177

output:

79848923155584

result:

ok single line: '79848923155584'

Test #19:

score: 0
Accepted
time: 4ms
memory: 3736kb

input:

7476400 3286922 144073

output:

332109011520

result:

ok single line: '332109011520'

Test #20:

score: 0
Accepted
time: 7ms
memory: 3696kb

input:

2528777 8583320 3053921

output:

86257168366272

result:

ok single line: '86257168366272'

Test #21:

score: 0
Accepted
time: 2ms
memory: 3636kb

input:

756027 9877774 6224461

output:

9145211051024

result:

ok single line: '9145211051024'

Test #22:

score: 0
Accepted
time: 3ms
memory: 3640kb

input:

1799348 1545770 5903860

output:

31551400528464

result:

ok single line: '31551400528464'

Test #23:

score: 0
Accepted
time: 6ms
memory: 3664kb

input:

2866047 8448813 9201454

output:

131427537714224

result:

ok single line: '131427537714224'

Test #24:

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

input:

3253 19822 15760

output:

169234080

result:

ok single line: '169234080'

Test #25:

score: 0
Accepted
time: 5ms
memory: 3704kb

input:

18973 6799 2004

output:

64208160

result:

ok single line: '64208160'

Test #26:

score: 0
Accepted
time: 4ms
memory: 3736kb

input:

1607 25903 7685

output:

41280624

result:

ok single line: '41280624'

Test #27:

score: 0
Accepted
time: 2ms
memory: 3676kb

input:

8763 27091 27201

output:

1228432400

result:

ok single line: '1228432400'

Test #28:

score: 0
Accepted
time: 6ms
memory: 3724kb

input:

3275 1018 17315

output:

16556752

result:

ok single line: '16556752'

Test #29:

score: 0
Accepted
time: 5ms
memory: 3708kb

input:

31480 24767 5816

output:

541074112

result:

ok single line: '541074112'

Test #30:

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

input:

22046 8058 12456

output:

985126032

result:

ok single line: '985126032'

Test #31:

score: 0
Accepted
time: 4ms
memory: 3708kb

input:

10321 22446 10938

output:

1327450496

result:

ok single line: '1327450496'

Test #32:

score: 0
Accepted
time: 4ms
memory: 3704kb

input:

14930 18763 2124

output:

72131040

result:

ok single line: '72131040'

Test #33:

score: 0
Accepted
time: 4ms
memory: 3588kb

input:

18366 14707 1959

output:

61355888

result:

ok single line: '61355888'

Test #34:

score: 0
Accepted
time: 4ms
memory: 3788kb

input:

4 4 4

output:

96

result:

ok single line: '96'

Test #35:

score: 0
Accepted
time: 4ms
memory: 3708kb

input:

5 5 5

output:

192

result:

ok single line: '192'

Test #36:

score: 0
Accepted
time: 2ms
memory: 3696kb

input:

6 6 6

output:

288

result:

ok single line: '288'

Test #37:

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

input:

7 7 7

output:

432

result:

ok single line: '432'

Test #38:

score: 0
Accepted
time: 4ms
memory: 3700kb

input:

8 8 8

output:

576

result:

ok single line: '576'

Test #39:

score: 0
Accepted
time: 2ms
memory: 3708kb

input:

9 9 9

output:

768

result:

ok single line: '768'

Test #40:

score: 0
Accepted
time: 4ms
memory: 3664kb

input:

10 10 10

output:

960

result:

ok single line: '960'