結果
| 問題 |
No.3260 岩井スターグラフ
|
| コンテスト | |
| ユーザー |
Akidai
|
| 提出日時 | 2025-09-06 13:25:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 338 ms / 2,000 ms |
| コード長 | 1,287 bytes |
| コンパイル時間 | 4,612 ms |
| コンパイル使用メモリ | 253,512 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-09-06 13:25:49 |
| 合計ジャッジ時間 | 14,849 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 36 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = (1LL << 62) - (1LL << 31) - 1;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)
#define RREP(i, init, n) for(int i = (int)(init); i >= (int)(n); i--)
#define All(A) A.begin(), A.end()
#define rAll(A) A.rbegin(), A.rend()
#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>
long X, Y, N;
vector<plong> P;
void solve() {
REP(i, 0, N) {
long u = P[i].first;
long v = P[i].second;
if(u == 0) {
cout << (v - 1) % Y + 1 << endl;
} else if(v == 0) {
cout << (u - 1) % Y + 1 << endl;
} else if((u - 1) / Y == (v - 1) / Y) {
long ans = abs(((u - 1) % Y) - ((v - 1) % Y));
cout << ans << endl;
} else {
long ans = ((u - 1) % Y) + ((v - 1) % Y) + 2;
cout << ans << endl;
}
}
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cin >> X >> Y >> N;
P.resize(N);
REP(i, 0, N) cin >> P[i].first >> P[i].second;
solve();
}
Akidai