QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#412475#8674. Riddle of the SphinxsupepapupuAC ✓1ms3644kbC++202.0kb2024-05-16 15:00:152024-05-16 15:00:17

Judging History

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

  • [2024-05-16 15:00:17]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3644kb
  • [2024-05-16 15:00:15]
  • 提交

answer

#include <bits/stdc++.h>

#define x first
#define y second
#define el '\n'
#define debug(x) cerr << #x << ": " << x << el
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 3e5 + 10, INF = 0x3f3f3f3f, mod = 998244353;
const double eps = 1e-8;

int n = 3;
double a[5][5];

int gauss() {
    int c, r;
    for (c = 0, r = 0; c < n; ++c) {
        int t = r;
        for (int i = r; i < n; ++i)
            if (fabs(a[i][c]) > fabs(a[t][c]))
                t = i;
        if (fabs(a[t][c]) < eps) continue;
        for (int i = c; i <= n; ++i) swap(a[t][i], a[r][i]);
        for (int i = n; i >= c; --i) a[r][i] /= a[r][c];
        for (int i = r + 1; i < n; ++i)
            if (fabs(a[i][c]) > eps)
                for (int j = n; j >= c; --j)
                    a[i][j] -= a[r][j] * a[i][c];
        ++r;
    }
    if (r < n) {
        for (int i = r; i < n; ++i)
            if (fabs(a[i][n]) > eps)
                return 2;
        return 1;
    }
    for (int i = n - 1; i >= 0; --i)
        for (int j = i + 1; j < n; ++j)
            a[i][n] -= a[i][j] * a[j][n];
    return 0;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int b[][4]{
        {1, 0, 0},
        {0, 1, 0},
        {0, 0, 1},
        {1, 2, 1},
        {2, 1, 1}
    };
    for (int i = 0; i < 5; ++i) {
        for (int j = 0; j < 3; ++j) cout << b[i][j] << ' ';
        cout << endl;
        cin >> b[i][3];
    }
    for (int i = 0; i < 5; ++i) {
        for (int j = 0, k = 0; j < 5; ++j) {
            if (j == i) continue;
            for (int x = 0; x < 4; ++x) a[k][x] = b[j][x];
            ++k;
        }
        gauss();
        for (int x = 0; x < 3; ++x) a[3][3] -= a[3][x] * a[x][3];
        if (abs(a[3][3]) < eps) {
            for (int x = 0; x < 3; ++x) cout << (int)(a[x][3] + 0.5) << ' ';
            cout << endl;
            return 0;
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3512kb

input:

1
2
3
8
7

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
1 2 3 

result:

ok correct!

Test #2:

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

input:

9998
1
1
10001
19998

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
9998 1 1 

result:

ok correct!

Test #3:

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

input:

3333
3333
3333
13332
13332

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
3333 3333 3333 

result:

ok correct!

Test #4:

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

input:

892
503
712
2611
3001

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
893 503 712 

result:

ok correct!

Test #5:

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

input:

868
365
947
2549
3050

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
868 367 947 

result:

ok correct!

Test #6:

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

input:

684
827
794
3131
2988

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
684 827 793 

result:

ok correct!

Test #7:

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

input:

308
23
440
792
1079

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
308 23 440 

result:

ok correct!

Test #8:

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

input:

705
910
341
2866
2662

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
705 910 341 

result:

ok correct!

Test #9:

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

input:

1482
1285
299
4350
4546

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
1481 1285 299 

result:

ok correct!

Test #10:

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

input:

1516
3576
839
9505
7446

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
1516 3575 839 

result:

ok correct!

Test #11:

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

input:

2254
132
1126
3645
5767

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
2254 132 1127 

result:

ok correct!

Test #12:

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

input:

801
38
56
932
1696

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
801 38 56 

result:

ok correct!

Test #13:

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

input:

1004
1248
3876
7376
7131

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
1004 1248 3876 

result:

ok correct!

Test #14:

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

input:

2011
3884
1618
11399
9528

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
2013 3884 1618 

result:

ok correct!

Test #15:

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

input:

1256
6632
214
14736
9359

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
1256 6633 214 

result:

ok correct!

Test #16:

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

input:

805
4142
694
9782
6445

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
805 4142 693 

result:

ok correct!

Test #17:

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

input:

731
4440
1054
10663
6956

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
731 4440 1054 

result:

ok correct!

Test #18:

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

input:

445
3442
4035
11364
8368

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
445 3442 4035 

result:

ok correct!

Test #19:

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

input:

1750
2
3
8
7

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
1 2 3 

result:

ok correct!

Test #20:

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

input:

1
2
3
8
7

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
1 2 3 

result:

ok correct!

Test #21:

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

input:

1
2
3
8
7

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
1 2 3 

result:

ok correct!

Test #22:

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

input:

1
2
3
11571
7

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
1 2 3 

result:

ok correct!

Test #23:

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

input:

1
2
3
8
6

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
1 2 3 

result:

ok correct!

Test #24:

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

input:

1633
1
1
10001
19998

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
9998 1 1 

result:

ok correct!

Test #25:

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

input:

9998
1
1
10001
19998

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
9998 1 1 

result:

ok correct!

Test #26:

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

input:

9998
1
671
10001
19998

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
9998 1 1 

result:

ok correct!

Test #27:

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

input:

9998
1
1
10000
19998

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
9998 1 1 

result:

ok correct!

Test #28:

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

input:

9998
1
1
10001
8025

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
9998 1 1 

result:

ok correct!

Test #29:

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

input:

3332
3333
3333
13332
13332

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
3333 3333 3333 

result:

ok correct!

Test #30:

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

input:

3333
3332
3333
13332
13332

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
3333 3333 3333 

result:

ok correct!

Test #31:

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

input:

3333
3333
3333
13332
13332

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
3333 3333 3333 

result:

ok correct!

Test #32:

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

input:

3333
3333
3333
13334
13332

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
3333 3333 3333 

result:

ok correct!

Test #33:

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

input:

3333
3333
3333
13332
13333

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
3333 3333 3333 

result:

ok correct!

Test #34:

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

input:

548
588
724
2443
2398

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
543 588 724 

result:

ok correct!

Test #35:

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

input:

780
1559
783
3485
3304

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
780 961 783 

result:

ok correct!

Test #36:

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

input:

690
189
313
1380
1881

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
690 189 312 

result:

ok correct!

Test #37:

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

input:

97
289
971
1647
1454

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
97 289 971 

result:

ok correct!

Test #38:

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

input:

298
118
177
711
6630

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
298 118 177 

result:

ok correct!

Test #39:

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

input:

2974
1358
2553
8243
9859

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
2974 1358 2553 

result:

ok correct!

Test #40:

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

input:

4209
360
3000
11525
13576

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
4209 2158 3000 

result:

ok correct!

Test #41:

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

input:

1199
99
4408
5805
6905

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
1199 99 4408 

result:

ok correct!

Test #42:

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

input:

3601
167
1004
4940
8373

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
3601 167 1004 

result:

ok correct!

Test #43:

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

input:

2721
2111
2489
9432
10041

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
2721 2111 2489 

result:

ok correct!

Test #44:

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

input:

551
203
5220
9323
12817

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
3697 203 5220 

result:

ok correct!

Test #45:

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

input:

1481
1259
1264
7195
6451

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
1481 2225 1264 

result:

ok correct!

Test #46:

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

input:

4769
1552
235
8264
11481

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
4769 1552 391 

result:

ok correct!

Test #47:

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

input:

1620
3589
1642
10441
8471

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
1620 3589 1642 

result:

ok correct!

Test #48:

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

input:

1136
6652
800
15240
9726

output:

1 0 0 
0 1 0 
0 0 1 
1 2 1 
2 1 1 
1136 6652 800 

result:

ok correct!

Extra Test:

score: 0
Extra Test Passed