結果
問題 |
No.3260 岩井スターグラフ
|
ユーザー |
|
提出日時 | 2025-09-06 15:35:03 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 344 ms / 2,000 ms |
コード長 | 5,346 bytes |
コンパイル時間 | 3,152 ms |
コンパイル使用メモリ | 283,960 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-06 15:35:31 |
合計ジャッジ時間 | 14,285 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 |
ソースコード
#include <bits/stdc++.h> // #include <atcoder/modint> using namespace std; #ifdef INCLUDE_MAIN // <-- based on mind_cpp void solve() { LL(X, Y, N); Vl(U, V, N); auto detect_Aid = [&](ll x) -> ll { if (x == 0) return -1; return (x - 1) / Y; }; rep(i, N) { auto u = U[i], v = V[i]; if (u == 0 && v == 0) out(0); else { if (v == 0) swap(u, v); if (u == 0) { v = (v - 1) % Y; out(v + 1); } else { ll Aidu = detect_Aid(u); ll Aidv = detect_Aid(v); ll distu = (u - 1) % Y; ll distv = (v - 1) % Y; if (Aidu == Aidv) { out(abs(distu - distv)); } else { out(distu + distv + 2); } } } } } // clang-format off int main() { ll Q = 1; // cin >> Q; rep(Q) { solve(); } return 0; } #else #define INCLUDE_MAIN // --- template --- #ifndef LOCAL #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #endif struct IOSetting {IOSetting() {std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}} iosetting; // alias #define all(x) (x).begin(),(x).end() #define Bit(n) (1LL<<(n)) typedef long long ll; typedef long double ld; typedef pair<ll,ll> pl; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<vvl> vvvl; typedef vector<ld> vd; typedef vector<vd> vvd; typedef vector<vvd> vvvd; typedef vector<bool> vb; typedef vector<vb> vvb; typedef vector<vvb> vvvb; typedef vector<pl> vpl; typedef vector<vpl> vvpl; typedef vector<vvpl> vvvpl; typedef vector<string> vs; typedef vector<vs> vvs; typedef vector<vvs> vvvs; // repeat #define overload4(_1,_2,_3,_4,name,...) name #define _rep1(n) _rep2(_,n) #define _rep2(i,n) for(ll i = 0; i < (n); i++) #define _rep3(i,a,b) for(ll i = (a); i < (b); i++) #define _rep4(i,a,b,c) for(ll i = (a); i < (b); i += (c)) #define rep(...) overload4(__VA_ARGS__,_rep4,_rep3,_rep2,_rep1)(__VA_ARGS__) #define _rrep1(n) _rrep2(i,0,n) #define _rrep2(i,n) for(ll i = (n) - 1; i >= 0; i--) #define _rrep3(i,a,b) for(ll i = (a); i > (b); i--) #define _rrep4(i,a,b,c) for(ll i = (a); i > (b); i -= (c)) #define rrep(...) overload4(__VA_ARGS__,_rrep4,_rrep3,_rrep2,_rrep1)(__VA_ARGS__) #define fore(x,a) for(auto &&x:a) #define rep1(i,n) rep(i,1,n+1) // input #define vec(type,name,...) vector<type> name(__VA_ARGS__) #define vv(type,name,n,...) vector name(n,vector<type>(__VA_ARGS__)) #define vvv(type,name,h,w,...) vector name(h,vector(w,vector<type>(__VA_ARGS__))) #define vvvv(type,name,a,b,c,...) vector name(a,vector(b,vector(c,vector<type>(__VA_ARGS__)))) #define VVl(name,h,w) vector<vector<ll>> name(h,vector<ll>(w)); rep(i,h) rep(j,w) cin >> name[i][j] #define Vs(name,n) vector<string> name(n); rep(i,n) cin >> name[i] #define LL(...) ll __VA_ARGS__; in(__VA_ARGS__) #define LD(...) ld __VA_ARGS__; in(__VA_ARGS__) #define PL(...) pl __VA_ARGS__; in(__VA_ARGS__) #define STR(...) string __VA_ARGS__; in(__VA_ARGS__) #define VEC(type,name,n) vec(type,name,n); rep(i,n) cin >> name[i] #define _Vl1(n) cout<<"error"<<endl #define _Vl2(a,n) vl a(n); rep(i,n) cin >> a[i] #define _Vl3(a,b,n) vl a(n),b(n); rep(i,n) cin >> a[i] >> b[i] #define _Vl4(a,b,c,n) vl a(n),b(n),c(n); rep(i,n) cin >> a[i] >> b[i] >> c[i] #define _Vl5(a,b,c,d,n) vl a(n),b(n),c(n),d(n); rep(i,n) cin >> a[i] >> b[i] >> c[i] >> d[i] #define _Vl6(a,b,c,d,e,n) vl a(n),b(n),c(n),d(n),e(n); rep(i,n) cin >> a[i] >> b[i] >> c[i] >> d[i] >> e[i] #define overload5(_1,_2,_3,_4,_5,name,...) name #define Vl(...) overload5(__VA_ARGS__,_Vl5,_Vl4,_Vl3,_Vl2,_Vl1)(__VA_ARGS__) #define VV(type,name,h,w) vv(type,name,h,w); rep(i,h) rep(j,w) cin >> name[i][j] template <class... T> void lisin(ll N, T&... a) { rep(i, N)((a.resize(N), cin >> a[i]), ...); } // overload >> template <class T1, class T2> istream& operator>>(istream& is, pair<T1, T2>& p) { is >> p.first >> p.second; return is; } template <class T> istream& operator>>(istream& is, vector<T>& v) { for(auto& c:v) is >> c; return is; } template<class... T> void in(T&... a){ ((cin >> a), ...); } // overload << template <class T1, class T2> ostream& operator<<(ostream& os, pair<T1, T2>& p) { os << p.first << " " << p.second; return os; } template <class T> ostream& operator<<(ostream& os, vector<T>& v) { rep(i, v.size()) { if (i) os << " "; os << v[i]; } return os; } template <class T> void out(vector<vector<T>>& v) { rep(i, v.size()) {cout << v[i] << endl;} } template <class T> void out(T a) { cout << a << endl; } template <class... T> void out(T... args) { ((cout << args << " "), ...); cout << endl; } void out(vs& v) { rep(i, v.size()) {cout << v[i] << "\n";} cout.flush(); } // debug (based on @naskya) #ifdef LOCAL #define deb(...) do { cerr << "\033[33m(line:" << __LINE__ << ") " ; out(#__VA_ARGS__, __VA_ARGS__); cerr << "\033[m"; } while(0) #else #define deb(...) do {} while(0) #endif // function template<class T1, class T2> bool chmax(T1& a, T2&& b) { if (a < b) { a = (T1)b; return 1; } return 0; } template<class T1, class T2> bool chmin(T1& a, T2&& b) { if (a > b) { a = (T1)b; return 1; } return 0; } int Yes(bool t = true){ cout << (t ? "Yes" : "No") << endl; return 0; } int No(){ return Yes(false); } // constant const ll infl = 1LL << 60; const ld eps = 1e-9; #include __FILE__ #endif