結果
問題 | No.2797 Square Tile |
ユーザー |
|
提出日時 | 2024-06-29 14:52:08 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 27 ms / 2,000 ms |
コード長 | 1,938 bytes |
コンパイル時間 | 5,100 ms |
コンパイル使用メモリ | 318,252 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-29 14:52:16 |
合計ジャッジ時間 | 7,160 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
ソースコード
#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(){ int a,b; cin >> 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,y+=k; 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,y+=k; 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,y+=k; 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,y+=k; 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"; } }