結果

問題 No.3260 岩井スターグラフ
コンテスト
ユーザー frontend annotation
提出日時 2025-11-11 16:28:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 595 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 44,012 KB
実行使用メモリ 7,840 KB
最終ジャッジ日時 2025-11-11 16:28:37
合計ジャッジ時間 7,659 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other AC * 1 WA * 35
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:27:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |   scanf("%d%d%d", &x, &y, &n);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:31:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |     scanf("%lld%lld", &u, &v);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<cstdio>
#include<algorithm>
#include<utility>

using namespace std;

/* constant */

/* typedef */

using ll = long long;
using pii = pair<int,int>;

/* global variables */

/* subroutines */

pii p2ij(ll p, int y) {
  if (p == 0) return {0, 0};
  return {(p - 1) / y, (p - 1) % y + 1};
}

/* main */

int main() {
  int x, y, n;
  scanf("%d%d%d", &x, &y, &n);

  while (n--) {
    ll u, v;
    scanf("%lld%lld", &u, &v);
    if (u > v) swap(u, v);

    auto [ui, uj] = p2ij(u, y);
    auto [vi, vj] = p2ij(v, y);

    printf("%d\
", (ui == vi) ? vj - uj : uj + vj);
  }

  return 0;
}
0