QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#707342 | #2511. Pyramid | becaido | AC ✓ | 1780ms | 406800kb | C++20 | 1.1kb | 2024-11-03 15:34:41 | 2024-11-03 15:34:42 |
Judging History
answer
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#ifdef WAIMAI
#define debug(HEHE...) cout<<"["<<#HEHE<<"] : ",dout(HEHE)
void dout(){cout<<'\n';}
template<typename T,typename...U>
void dout(T t,U...u){cout<<t<<(sizeof...(u)?", ":""),dout(u...);}
#else
#define debug(...) 7122
#endif
#define ll long long
#define Waimai ios::sync_with_stdio(false),cin.tie(0)
#define FOR(x,a,b) for(int x=a,I=b;x<=I;x++)
#define pb emplace_back
#define F first
#define S second
const int SIZE = 1e4 + 5;
int n, k;
int a[SIZE][SIZE];
bitset<SIZE> dir[SIZE];
void solve() {
cin >> n >> k;
for (int i = 1; i <= n; i++) fill (a[i], a[i] + n + 1, 0);
k--;
a[1][1] = k;
for (int i = 1; i <= n; i++) for (int j = 1; j <= n - i; j++) {
dir[i][j] = a[i][j] & 1;
a[i + 1][j] += (a[i][j] + 1) >> 1;
a[i][j + 1] += a[i][j] >> 1;
}
int x = 1, y = 1;
while (x + y <= n) {
if (dir[x][y]) y++;
else x++;
}
cout << n - x << '\n';
}
int32_t main() {
Waimai;
int tt;
cin >> tt;
while (tt--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5720kb
input:
2 5 1 5 2
output:
0 1
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 5744kb
input:
3 5 3 5 4 5 5
output:
2 3 2
result:
ok 3 lines
Test #3:
score: 0
Accepted
time: 1780ms
memory: 406800kb
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