結果

問題 No.2797 Square Tile
ユーザー makichan
提出日時 2024-06-28 23:39:01
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,981 bytes
コンパイル時間 6,773 ms
コンパイル使用メモリ 316,840 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2024-06-28 23:39:11
合計ジャッジ時間 8,171 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 14 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using mint = atcoder::static_modint<998244353>;
//using mint = atcoder::static_modint<1000000007>;
using namespace std;
using namespace atcoder;
using ld = long double;
using ll = long long;
#define mp(a,b) make_pair(a,b)
#define rep(i,s,n) for(int i=s; i<n; i++)

int main(){
    ll a,b;
    cin >> a >> b;
    if(a>b)swap(a,b);
    if(a==b){
        set<pair<ll,ll>> S;
        int k=a*a+b*b;
        rep(i,0,2*a)rep(j,0,2*a)S.insert(mp(i*a,j*a));
        for(auto p:S)cout << p.first << " " << p.second << "\n";
    }
    else{
        ll k=a*a+b*b;
        set<pair<ll,ll>> A,B;
        queue<pair<ll,ll>> Q;
        Q.push(mp(0,0));
        A.insert(mp(0,0));
        while(Q.size()>0){
            auto p=Q.front();
            Q.pop();
            ll x=p.first,y=p.second;
            x+=a,y+=b;
            x+=k*10,y+=k*10;
            x%=k,y%=k;
            if(A.find(mp(x,y))==A.end()){
                Q.push(mp(x,y));
                A.insert(mp(x,y));
            }
            x-=a,y-=b;

            x+=b,y-=a;
            x+=k*10,y+=k*10;
            x%=k,y%=k;
            if(A.find(mp(x,y))==A.end()){
                Q.push(mp(x,y));
                A.insert(mp(x,y));
            }
            x-=b,y+=a;

            x-=a,y-=b;
            x+=k*10,y+=k*10;
            x%=k,y%=k;
            if(A.find(mp(x,y))==A.end()){
                Q.push(mp(x,y));
                A.insert(mp(x,y));
            }
            x+=a,y+=b;

            x-=b,y+=a;
            x+=k*10,y+=k*10;
            x%=k,y%=k;
            if(A.find(mp(x,y))==A.end()){
                Q.push(mp(x,y));
                A.insert(mp(x,y));
            }
        }
        for(auto p:A){
            ll x=p.first,y=p.second;
            x+=a;
            x%=k;
            B.insert(mp(x,y));
        }

        for(auto p:A)cout << p.first << " " << p.second << "\n";
        for(auto p:B)cout << p.first << " " << p.second << "\n";
    }
}
0