Submission #18998101


Source Code Expand

Copy
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


enum E = 10;

void main() {
  try {
    for (; ; ) {
      const N = readInt();
      
      auto rot = new int[1 << E];
      foreach (u; 0 .. 1 << E) {
        rot[u] = (u & ((1 << (E - 1)) - 1)) << 1 | (u >> (E - 1));
      }
      debug {
        writeln("rot = ", rot);
      }
      
      auto A = new int[N];
      auto B = new int[N];
      foreach (u; 0 .. N) {
        A[u] = (u * 2) % N;
        B[u] = (u * 2 + 1) % N;
      }
      
      foreach (u; 0 .. N) {
        writeln(A[u] + 1, " ", B[u] + 1);
      }
      
      debug {
        foreach (s; 0 .. N) {
          DList!int que;
          auto dist = new int[N];
          dist[] = N;
          dist[s] = 0;
          que ~= s;
          for (; !que.empty; ) {
            const u = que.front;
            que.removeFront;
            foreach (v; [A[u], B[u]]) {
              if (chmin(dist[v], dist[u] + 1)) {
                que ~= v;
              }
            }
          }
          foreach (u; 0 .. N) {
            assert(dist[u] <= 10, format("%s %s: %s", s, u, dist[u]));
          }
        }
      }
    }
  } catch (EOFException e) {
  }
}

Submission Info

Submission Time
Task A - AtCoder Jumper
User hos_lyric
Language D (LDC 1.20.1)
Score 500
Code Size 2368 Byte
Status AC
Exec Time 8 ms
Memory 3400 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 12
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 8 ms 3368 KB
001.txt AC 4 ms 3324 KB
002.txt AC 4 ms 3400 KB
003.txt AC 6 ms 3192 KB
004.txt AC 4 ms 3300 KB
005.txt AC 4 ms 3296 KB
006.txt AC 4 ms 3304 KB
007.txt AC 4 ms 3328 KB
008.txt AC 4 ms 3328 KB
009.txt AC 4 ms 3108 KB
example0.txt AC 7 ms 3400 KB
example1.txt AC 4 ms 3336 KB