結果
| 問題 | No.2797 Square Tile | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-06-28 23:34:48 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,983 bytes | 
| コンパイル時間 | 5,420 ms | 
| コンパイル使用メモリ | 317,468 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-28 23:34:56 | 
| 合計ジャッジ時間 | 7,242 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 14 WA * 7 | 
ソースコード
#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();
            int 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){
            int 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";
    }
}
            
            
            
        