QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#585400 | #2511. Pyramid | CSQ | AC ✓ | 852ms | 393116kb | C++23 | 1.2kb | 2024-09-23 20:39:32 | 2024-09-23 20:39:32 |
Judging History
answer
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define all(x) begin(x),end(x)
#define sz(x) (int)(x).size();
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int MAXN = 1e4;
int ball[MAXN][MAXN];
int main()
{
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
int t;
cin>>t;
while(t--){
int n,k;
cin>>n>>k;
ball[0][0] = k;
int x = 0,y = 0;
for(int lvl=0;lvl+1<n;lvl++){
for(int i=lvl;i>=0;i--){
int j = lvl-i;
if(!ball[i][j])break;
ball[i][j+1] += ball[i][j]>>1;
ball[i+1][j] += (ball[i][j]+1)>>1;
if(i == x && j == y){
if(ball[i][j]%2 == 0)y++;
else x++;
}
//cout<<i<<" "<<j<<" "<<ball[i][j]<<'\n';
ball[i][j] = 0;
}
}
for(int i=0;i<n;i++)ball[i][n-1-i] = 0;
cout<<y<<'\n';
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3716kb
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: 852ms
memory: 393116kb
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