結果

問題 No.3260 岩井スターグラフ
ユーザー tau1235
提出日時 2025-09-06 13:56:15
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 518 ms / 2,000 ms
コード長 352 bytes
コンパイル時間 3,267 ms
コンパイル使用メモリ 275,212 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-06 13:56:38
合計ジャッジ時間 17,184 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
  using ll=long long;
  ll x,y,n;
  cin>>x>>y>>n;
  while (n--){
    ll ans=0;
    ll u,v;
    cin>>u>>v;
    if (u>v) swap(u,v);
    ll d1=(u-1)%y+1,d2=(v-1)%y+1;
    if (u==0) ans=d2;
    else{
      if ((u-1)/y==(v-1)/y) ans=abs(d1-d2);
      else ans=d1+d2;
    }
    cout<<ans<<endl;
  }
}
0