結果
| 問題 |
No.2393 Bit Grid Connected Component
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-01 22:42:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,275 bytes |
| コンパイル時間 | 2,118 ms |
| コンパイル使用メモリ | 182,200 KB |
| 実行使用メモリ | 108,324 KB |
| 最終ジャッジ日時 | 2024-10-11 18:20:56 |
| 合計ジャッジ時間 | 6,993 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 9 TLE * 1 -- * 10 |
ソースコード
#include <bits/stdc++.h>
#include <iterator>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define debug 1
using ll = long long;
using ld = long double;
const int mod = 998244353;
const double pi = atan2(0, -1);
#include <time.h>
#include <chrono>
int main() {
int T;
cin >> T;
rep(test, T) {
ll x, y;
cin >> x >> y;
set<vector<ll>> s;
s.insert({ x,y });
queue<vector<ll>> q;
q.push({ x,y });
while (!q.empty()) {
ll nowx = q.front()[0];
int nowy = q.front()[1];
q.pop();
if (nowx > 1) {
bitset<60> b = nowx - 1;
if (b[nowy]&&!s.count({nowx-1, nowy})) {
s.insert({ nowx - 1, nowy });
q.push({ nowx - 1 , nowy });
}
}
if (nowy > 0) {
bitset<60>b = nowx;
if (b[nowy - 1] && !s.count({ nowx, nowy - 1 })) {
s.insert({ nowx, nowy - 1 });
q.push({ nowx, nowy - 1 });
}
}
if (nowy < 59) {
bitset<60> b = nowx;
if (b[nowy + 1] && !s.count({ nowx, nowy + 1 })) {
s.insert({ nowx, nowy + 1 });
q.push({ nowx, nowy + 1 });
}
}
if (nowx+1LL < (1LL << 60LL)) {
bitset<60> b = nowx + 1;
if (b[nowy] && !s.count({ nowx + 1, nowy })) {
s.insert({ nowx + 1, nowy });
q.push({ nowx + 1, nowy });
}
}
}
cout << s.size() << endl;
}
}