QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#56953#2511. PyramidSa3tElSefrAC ✓778ms236784kbC++201013b2022-10-22 04:53:192022-10-22 04:53:21

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-10-22 04:53:21]
  • Judged
  • Verdict: AC
  • Time: 778ms
  • Memory: 236784kb
  • [2022-10-22 04:53:19]
  • Submitted

answer

#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>

#define ll long long
#define ld  double
using namespace std;

const int N = 10000 + 5, mod = 998244353;


int a[N][N];

// (k + 1) / 2
void solve(int n, int k) {
    for(int i = 0; i < n; i++) a[0][i] = 0;
    a[0][0] = k;
    for(int i = 0; i < n; i++) {
        for(int j = 0; i + j < n; j++) {
            a[i + 1][j] = ((a[i][j] + 1) >> 1);
            a[i][j + 1] += a[i][j] >> 1;
        }
    }
}




int generate(int n) {
    int r = 0, c = 0;
    for(int i = 1; i < n; i++) {
        if(a[r][c] % 2) {
            c++;
        }
        else r++;
    }
    return n - 1 - r;
}




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

    int tt;
    cin >> tt;
    while(tt--) {
        int n, k;
        cin >> n >> k;
        solve(n - 1, k - 1);
        cout << generate(n) << '\n';
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
5 1
5 2

output:

0
1

result:

ok 2 lines

Test #2:

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

input:

3
5 3
5 4
5 5

output:

2
3
2

result:

ok 3 lines

Test #3:

score: 0
Accepted
time: 778ms
memory: 236784kb

input:

20
10000 100000000
9999 98987654
1234 5678
5000 20091234
1 100
1 101
7777 77777777
5890 98767897
106 67898765
2 4
9999 98987655
9999 98987656
9999 98987657
9999 98987658
9999 98987659
9999 98987660
9999 98987661
9999 98987662
9999 98987663
9999 98987664

output:

4931
5021
614
2506
0
0
3971
2907
50
1
4968
5044
5049
5002
4998
4984
5055
5045
4991
5037

result:

ok 20 lines