QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#528407#2511. PyramidNYCU_CartesianTree#AC ✓2062ms393876kbC++20921b2024-08-23 13:37:132024-08-23 13:37:14

Judging History

This is the latest submission verdict.

  • [2024-08-23 13:37:14]
  • Judged
  • Verdict: AC
  • Time: 2062ms
  • Memory: 393876kb
  • [2024-08-23 13:37:13]
  • Submitted

answer

#include<iostream>
#include<vector>
using namespace std;

// #define int long long
#define pii pair<int, int>
#define F first 
#define S second 
#define N 10005

int dp[10005][10005];
void solve(){
    int n, k;
    cin >> n >> k;
    dp[0][0] = k - 1;
    for (int tot = 0; tot < n - 1; tot++){
        for (int i = 0; i <= tot + 1; i++)
            dp[i][tot - i + 1] = 0;
        for (int i = 0; i <= tot; i++){
            int j = tot - i;
            dp[i + 1][j] += dp[i][j] / 2 + (dp[i][j] & 1);
            dp[i][j + 1] += dp[i][j] / 2;
        }
    }
    int nowi = 0, nowj = 0;
    for (int t = 0; t < n - 1; t++){
        if(dp[nowi][nowj] & 1)
            nowj++;
        else
            nowi++;
    }
    cout << nowj << "\n";
}
signed main(){
    ios_base::sync_with_stdio(0), cin.tie(0);
    int t = 1;
    cin >> t;
    while(t--)
        solve();
    return 0;
}

详细

Test #1:

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

input:

2
5 1
5 2

output:

0
1

result:

ok 2 lines

Test #2:

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

input:

3
5 3
5 4
5 5

output:

2
3
2

result:

ok 3 lines

Test #3:

score: 0
Accepted
time: 2062ms
memory: 393876kb

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