結果

問題 No.3012 岩井星人グラフ
ユーザー friedrice
提出日時 2025-01-25 17:19:10
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 344 ms / 2,000 ms
コード長 2,721 bytes
コンパイル時間 6,963 ms
コンパイル使用メモリ 333,036 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-25 23:58:03
合計ジャッジ時間 13,330 ms
ジャッジサーバーID
(参考情報)
judge2 / judge7
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using mint = atcoder::modint998244353;
using maxt = atcoder::modint1000000007;
vector<ll> Era(int N) {
  vector<ll> ans(0, 0);
  vector<bool> isprime(N + 1, true);
  isprime.at(1) = false;
  for(int i = 1; i <= N; i++) {
    if(isprime.at(i)) {
      ans.push_back(i);
      for(int j = 2 * i; j <= N; j += i) {
        isprime.at(j) = false;
      }
    }
  }
  return ans;
}
ll POW(ll a, int N) {
  if(N == 1) {
    return a;
  }
  ll ans = POW(a, N / 2) * POW(a, N / 2);
  if(N % 2 == 1) {
    ans *= a;
  }
  return ans;
}
ll GCD(ll a, ll b) {
  if(b == 0) {
    return a;
  }
  int r = a % b;
  return GCD(b, r);
}
ll LCM(ll a, ll b) {
  return (a * b) / GCD(a, b);
}
vector<ll> zaatu(vector<ll> a) {
  vector<ll> b(0, 0);
  b = a;
  sort(b.begin(), b.end());
  b.erase(unique(b.begin(), b.end()), b.end());
  int s = b.size();
  for(ll &o : a) {
    int l = 0, r = s, c = 0;
    while(r - l > 1) {
      c = (l + r) / 2;
      if(b.at(c) <= o) {
        l = c;
      }
      else {
        r = c;
      }
    }
    o = r;
  }
  return a;
}
struct FenwickTree {
  int N;
  vector<ll> a;
  
  FenwickTree(int n) {
    N = n;
    a.assign(N + 1, 0);
  }
  
  void add(int i, ll x) {
    for(int j = i; j <= N; j += (j & -j)) {
      a.at(j) += x;
    }
  }
  
  ll sum(int i, int j) {
    return sum_sub(j) - sum_sub(i - 1);
  }
  
  ll sum_sub(int i) {
    if(i == 0) {
      return 0;
    }
    ll s = 0;
    for(int j = i; j > 0; j -= (j & -j)) {
      s += a.at(j);
    }
    return s;
  }
};
ll tento(vector<ll> a) {
  int s = a.size();
  FenwickTree tmp(s);
  ll ans = 0;
  for(int i = 0; i < s; i++) {
    ans += i - tmp.sum_sub(a.at(i));
    tmp.add(a.at(i), 1);
  }
  return ans;
}
struct UnionFind {
  vector<int> par;
  
  UnionFind(int N) {
    par.assign(N + 1, 0);
  }
  
  int root(int x) {
    if(par.at(x) == 0) {
      return x;
    }
    return par.at(x) = root(par.at(x));
  }
  
  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if(rx != ry) {
      par.at(rx) = ry;
    }
  }
  
  bool same(int x, int y) {
    return root(x) == root(y);
  }
};
//library end

int query(int c) {
  cout << c << endl;
  int r;
  cin >> r;
  return r;
}

int main() {
  int X, Y;
  cin >> X >> Y;
  cout << X * Y << ' ' << X * Y << endl;
  for(int i = 0; i < Y - 1; i++) {
    for(int j = 1; j <= X; j++) {
      cout << i * X + j << ' ' << (i + 1) * X + j << endl;
    }
  }
  for(int i = X * Y - X + 1; i <= X * Y; i++) {
    if(i == X * Y) {
      cout << i << ' ' << X * Y - X + 1 << endl;
    }
    else {
      cout << i  << ' ' << i + 1 << endl;
    }
  }
}
0