結果
問題 |
No.3260 岩井スターグラフ
|
ユーザー |
|
提出日時 | 2025-09-06 13:14:19 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 549 ms / 2,000 ms |
コード長 | 2,150 bytes |
コンパイル時間 | 6,071 ms |
コンパイル使用メモリ | 334,176 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-09-06 13:16:24 |
合計ジャッジ時間 | 20,871 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 |
ソースコード
#include <atcoder/all> #include <bits/stdc++.h> using namespace std; using namespace atcoder; using ll = long long; using ld = long double; ll INF = 2e18; template<typename T> using vc = vector<T>; template<typename T> using vv = vc<vc<T>>; #define MP(a, b) make_pair(a, b) #define nfor(i,s,n) for(ll i=s;i<(ll)n;i++) #define rep(i,n) for(ll i = 0; i < (n); i++) using vl = vc<ll>; using vvl = vv<ll>; using vvvl = vv<vl>; using vvvvl = vv<vvl>; using vs = vc<string>; using vvs = vv<string>; using vb = vc<bool>; using vvb = vv<bool>; using vvvb = vv<vb>; using vld = vc<ld>; using vvld = vv<ld>; using vvvld = vv<vld>; using P = pair<ll, ll>; template<class T>istream& operator>>(istream& i, vc<T>& v) { rep(j, size(v))i >> v[j]; return i; } template<class T> using pq = priority_queue<T, vc<T>>;//大きい順 template<class T> using pq_g = priority_queue<T, vc<T>, greater<T>>;//小さい順 #define pb push_back #define pob pop_back #define all(s) s.begin(),s.end() #define YES std::cout<<"Yes"<<std::endl #define NO std::cout<<"No"<<std::endl #define YN {std::cout<<"Yes"<<std::endl;}else{std::cout<<"No"<<std::endl;} #define dame std::cout<<-1<<std::endl #define pop_cnt(s) ll(popcount(uint64_t(s))) #define yu_qurid(x,y) ((x)*(x)+(y)*(y)) #define mannhattan(x1,x2,y1,y2) (abs(x1-x2)+abs(y1-y2)) #define vc_cout(v){ll n = size(v);rep(i,n)std::cout<<v[i]<<std::endl;} #define vv_cout(v){ll n = size(v);rep(i,n){rep(j,size(v[i])){std::cout<<v[i][j]<<' ';}std::cout<<std::endl;}} using mint = atcoder::modint998244353; // using mint = atcoder::modint1000000007; using vm = vc<mint>; using vvm = vc<vm>; int main(){ ll x, y, n; cin >> x >> y >> n; rep(i, n){ ll a, b; cin >> a >> b; if(a == b){ cout << 0 << endl; continue; } if(a == 0 || b == 0){ a = max(a - 1, 0LL); b = max(b - 1, 0LL); cout << max(a % y, b % y) + 1 << endl; continue; } a--, b--; if(a / y == b / y){ cout << abs(a - b) << endl; }else{ cout << a % y + b % y + 2 << endl; } } }