結果

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

ソースコード

diff #

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

int main() {
    int X, Y, N;
    cin >> X >> Y >> N;
    vector<long long> U(N);
    vector<long long> V(N);
    for (int i = 0; i < N; ++i) cin >> U[i] >> V[i];
    for (int i = 0; i < N; ++i) {
    	int ans = 0;
    	if ((U[i] - 1) / Y == (V[i] - 1) / Y) {
    		ans = max(U[i], V[i]) - min(U[i], V[i]);
    	} else {
    		ans += (U[i] - 1) % Y;
    		ans += 2;
    		ans += (V[i] - 1) % Y;
    	}
    	cout << ans << endl;
    }
}
0