結果

問題 No.2797 Square Tile
ユーザー shobonvipshobonvip
提出日時 2024-06-21 23:15:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 2,342 bytes
コンパイル時間 2,566 ms
コンパイル使用メモリ 204,856 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-21 23:15:08
合計ジャッジ時間 4,476 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 3 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 10 ms
6,944 KB
testcase_05 AC 8 ms
6,944 KB
testcase_06 AC 5 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 AC 5 ms
6,940 KB
testcase_10 AC 7 ms
6,940 KB
testcase_11 AC 4 ms
6,944 KB
testcase_12 AC 5 ms
6,940 KB
testcase_13 AC 3 ms
6,944 KB
testcase_14 AC 5 ms
6,944 KB
testcase_15 AC 4 ms
6,940 KB
testcase_16 AC 3 ms
6,944 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 5 ms
6,940 KB
testcase_20 AC 4 ms
6,940 KB
testcase_21 AC 7 ms
6,940 KB
testcase_22 AC 3 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}

template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}

template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}

template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}



int main(){
	ll a, b;
	cin >> a >> b;
	ll n = a * a + b * b;
	ll area_left = n * n;

	ll a_left = n;
	ll b_left = n;
	ll x = 0;
	ll y = 0;
	vector<pair<ll,ll>> a_list;
	vector<pair<ll,ll>> b_list;

	ll g = __gcd(a, b);
	//vector imos(2*n+1, vector<int>(2*n+1));

	int mode = 0;
	for (int f=0; f<g; f++){
		for (int t=0; t<(a*a+b*b)/g*2; t++){
			//cout << x << ' ' << y << endl;
			if (mode == 0){
				a_list.push_back(pair(x, y));
				/*
				imos[x][y] += 1;
				imos[x+a][y] -= 1;
				imos[x][y+a] -= 1;
				imos[x+a][y+a] += 1;
				*/
				x += a;
				x %= n;
				a_left -= 1;
				area_left -= a * a;
			}else{
				b_list.push_back(pair(x, y));
				/*
				imos[x][y] += 1;
				imos[x+b][y] -= 1;
				imos[x][y+b] -= 1;
				imos[x+b][y+b] += 1;
				*/
				y += b;
				y %= n;
				b_left -= 1;
				area_left -= b * b;
			}
			mode ^= 1;
		}
		
		if (mode == 0){
			y += a;
			y %= n;
			x -= b;
			x += n;
			x %= n;
		}else{
			assert(false);
		}
		
	}

	assert(a_left == 0);
	assert(b_left == 0);
	assert(area_left == 0);

	/*
	rep(i,0,2*n+1){
		rep(j,0,2*n){
			imos[i][j+1] += imos[i][j];
		}
	}
	rep(i,0,2*n){
		rep(j,0,2*n+1){
			imos[i+1][j] += imos[i][j];
		}
	}
	vector v(n, vector<int>(n));
	rep(i,0,2*n+1){
		rep(j,0,2*n+1){
			v[i%n][j%n] += imos[i][j];
		}
	}
	rep(i,0,n){
		rep(j,0,n){
			if(v[i][j] > 0)cout << '#';
			else cout << '.';
		}
		cout<<'\n';
	}
	*/

	for (auto [x, y]: a_list){
		cout << x << ' ' << y << '\n';
	}
	for (auto [x, y]: b_list){
		cout << x << ' ' << y << '\n';
	}
	
}
0