結果

問題 No.2035 Tunnel
コンテスト
ユーザー occhan
提出日時 2026-07-19 13:41:52
言語 TypeScript
(6.0.2)
コンパイル:
tsc.sh -p tsconfig.json
実行:
node main.js ONLINE_JUDGE
結果
AC  
実行時間 47 ms / 2,000 ms
+ 906µs
コード長 3,728 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,252 ms
コンパイル使用メモリ 199,864 KB
実行使用メモリ 65,512 KB
最終ジャッジ日時 2026-07-19 13:42:03
合計ジャッジ時間 4,284 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// start

import * as fs from "node:fs";

function main() {
  // ここに処理を記述します

  let N = nextNum();
  let S = next().split("").reverse();
  let T = Array(N*2+5).fill(".");
  let idx = 0;
  let ans = 0;
  for (let i = 0; i < N; i++) {
    if (S[i] == ".") {
      if (i >= idx) idx++;
    } else {
      T[idx] = "#";
      ans = idx+1;
      idx+=2;
    }
  }
  print(ans);

  // 処理終了
}

const less = <T>(a: T, b: T) => (a == b ? 0 : a < b ? -1 : 1)
const greater = <T>(a: T, b: T) => (a == b ? 0 : a < b ? 1 : -1)
const bigIntMax = (...args: bigint[]) => args.reduce((m, e) => (e > m ? e : m))
const bigIntMin = (...args: bigint[]) => args.reduce((m, e) => (e < m ? e : m))
const bigIntAbs = (arg: bigint) => (arg < 0 ? -arg : arg)
const bigIntSqrt = (n: bigint) => {
  let x = BigInt(Math.floor(Math.sqrt(Number(n))));
  while ((x+1n)*(x+1n) <= n) {
    x++;
  }
  while (x*x > n) {
    x--;
  }
  return x;
}

let inputs = "";
let inputArray: string[];
let currentIndex = 0;

let outputBuffer = "";

let yes = "Yes";
let no = "No";
let MOD998244353 = 998244353;
let small_a_code = 97;
let big_A_code = 65;

let dxy4 = [[-1,0],[0,1],[1,0],[0,-1]];
let dxy8 = [[-1,0],[-1,1],[0,1],[1,1],[1,0],[1,-1],[0,-1],[-1,-1]];
let dir4 = ["U","R","D","L"];

// // インタラクティブ用
// // お決まりのインプットはコメントアウト、main関数にasyncを忘れない
// // 詳しくは典型ABC305-Fをチェック
// const readline = require("readline");
// const rl = readline.createInterface({
//   input: process.stdin,
//   output: process.stdout,
// });
// const it = rl[Symbol.asyncIterator]();
// const nextAwait = async () => {
//   const { value } = await it.next();
//   return value.trim();
// };

function next() {
  return inputArray[currentIndex++];
}
function nextNum() {
  return +next();
}
function nextBigInt() {
  return BigInt(next());
}
function nexts(length: number) {
  const arr: string[] = [];
  for(let i = 0; i < length; ++i) arr[i] = next();
  return arr;
}
function nextNums(length: number) {
  const arr: number[] = [];
  for(let i = 0; i < length; ++i) arr[i] = nextNum();
  return arr;
}
function nextBigInts(length: number) {
  const arr: bigint[] = [];
  for(let i = 0; i < length; ++i) arr[i] = nextBigInt();
  return arr;
}

function print(out: string | number | bigint): void;
function print<T>(out: Array<T>, separator: string): void;
function print<T>(out: string | number | bigint | Array<T>, separator?: string) {
  if (Array.isArray(out)) {
    outputBuffer += out.join(separator);
  } else {
    outputBuffer += out;
  }
}

function println(out: string | number | bigint): void;
function println<T>(out: Array<T>, separator: string): void;
function println<T>(out: string | number | bigint | Array<T>, separator?: string) {
  if (Array.isArray(out)) {
    print(out, separator || "");
  } else {
    print(out);
  }
  print("\n");
}

function flush() {
  console.log(outputBuffer);
}


// end

function readInput() {
  const g = globalThis as any;

  // Deno
  if (typeof g.Deno !== "undefined") {
    const chunks: Uint8Array[] = [];
    const buf = new Uint8Array(1 << 16);

    while (true) {
      const n = g.Deno.stdin.readSync(buf) as number | null;
      if (n === null) break;
      if (n > 0) chunks.push(buf.slice(0, n));
    }

    const length = chunks.reduce((s, c) => s + c.length, 0);
    const bytes = new Uint8Array(length);

    let offset = 0;
    for (const c of chunks) {
      bytes.set(c, offset);
      offset += c.length;
    }

    return new TextDecoder().decode(bytes);
  }

  // Node.js / Bun
  return fs.readFileSync(0, "utf8");
}

inputs = readInput();
inputArray = inputs.trim().split(/\s+/);
main();
flush();
0