結果
問題 | No.2797 Square Tile |
ユーザー | shobonvip |
提出日時 | 2024-06-21 23:15:03 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.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 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
ソースコード
#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'; } }