結果

問題 No.2393 Bit Grid Connected Component
ユーザー anago-pieanago-pie
提出日時 2023-08-01 22:42:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,275 bytes
コンパイル時間 1,940 ms
コンパイル使用メモリ 179,016 KB
実行使用メモリ 108,448 KB
最終ジャッジ日時 2024-04-19 23:37:30
合計ジャッジ時間 5,726 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 73 ms
9,600 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
	}
}
0