結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー Yang33Yang33
提出日時 2018-10-02 21:45:38
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,498 bytes
コンパイル時間 1,659 ms
コンパイル使用メモリ 173,860 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-02 14:27:33
合計ジャッジ時間 5,079 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/10/02  Problem: yukicoder 321  / Link: http://yukicoder.me/problems/no/321  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

void solve() {
	int H, W; H = W = 100;
	cout << "what is vec(P,Q)?" << endl;
	int P, Q; cin >> P >> Q;
	VVI m(2*H, VI(2*W, 0));

	m[H][W] = 2;
	queue<PII>q;
	q.push(PII(H, W));
	while (!q.empty()) {
		PII a = q.front(); q.pop();
		for (int i = -1; i < 2; i += 2) {
			for (int j = -1; j < 2; j += 2) {
				int ny = a.first + P * i;
				int nx = a.second + Q * j;
#define IN(x,y,z) (x<=y&&y<z)
				if (IN(0, ny, 2 * H) && IN(0, nx, 2 * W) && !m[ny][nx]) {
					m[ny][nx] = 1;
					q.push(PII(ny, nx));
				}
			}
		}
		for (int i = -1; i < 2; i += 2) {
			for (int j = -1; j < 2; j += 2) {
				int ny = a.first + Q * i;
				int nx = a.second + P * j;
				if (IN(0, ny, 2 * H) && IN(0, nx, 2 * W) && !m[ny][nx]) {
					m[ny][nx] = 1;
					q.push(PII(ny, nx));
				}
			}
		}
	}
	FOR(i, -20, 21) {
		FOR(j, -20, 21) {
			cout << m[i+H][j+W] << " ";
		}cout << endl;
	}
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	solve(); return 0;
	LL P, Q; cin >> P >> Q;
	LL G = __gcd(P, Q);
	if (G) {
		P = P / G;
		Q = Q / G;
	}
	LL N; cin >> N;

	FOR(i, 0, N) {
		LL x, y; cin >> x >> y;
		if (P == 0 && P == Q) {
			if (x == 0 && x == y)ans++;
		}
		else {
			if (x%G == 0 && y%G == 0) {
				x /= G, y /= G;
				if (P & 1 && Q & 1) {
					if ((x + y) % 2 == 0) {
						ans++;
					}
				}
				else {
					ans++;
				}
			}
		}

	}
	
	
	cout << ans << "\n";

	return 0;
}
0