結果
| 問題 |
No.3375 Binary Grid
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-21 23:04:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 838 bytes |
| コンパイル時間 | 1,760 ms |
| コンパイル使用メモリ | 195,768 KB |
| 実行使用メモリ | 7,852 KB |
| 最終ジャッジ日時 | 2025-11-21 23:04:38 |
| 合計ジャッジ時間 | 3,069 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 WA * 6 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:27:22: warning: ‘bt’ may be used uninitialized [-Wmaybe-uninitialized]
27 | while(x < bt && y < v){
| ~~~~~~~^~~~~~~~
main.cpp:21:12: note: ‘bt’ was declared here
21 | ll bt;
| ^~
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while(T--){
ll y, x;
cin >> y >> x;
x--;
ll msb = __lg(y), ans = 0, c = x;
while(y >> (c + 1) & 1) c++;
if(c == msb){
cout << y - 1 << '\n';
continue;
}
ll v = 1ll << msb;
ll bt;
for(int i = msb - 1; i >= 0; i--){
v |= 1ll << i;
bt = i;
if(v >= y) break;
}
while(x < bt && y < v){
if(~y >> (x + 1) & 1) break;
if((y + 1) >> (x + 1) & 1){
y++;
}
x++;
ans++;
}
ans += v - 1;
ans += v - y;
cout << ans << '\n';
}
}