Library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub jellc/Library

:heavy_check_mark: test/aizu-online-judge/ITP1_3_B.test.cpp

Depends on

Code

#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/problems/ITP1_3_B"

#include "src/sys/iteration.hpp"

namespace workspace {

void main() {
  int x;
  std::cin >> x;
  if (!x) exit();
  std::cout << "Case " << case_info.current << ": " << x << std::endl;
}

}  // namespace workspace

int main() {
  workspace::case_info.total = -1;
  return workspace::case_info.iterate();
}
#line 1 "test/aizu-online-judge/ITP1_3_B.test.cpp"
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/problems/ITP1_3_B"

#line 2 "src/sys/iteration.hpp"

/**
 * @file iteration.hpp
 * @brief Case Iteration
 */

#include <cassert>

#line 2 "src/sys/ejection.hpp"

/**
 * @file ejection.hpp
 * @brief Ejection
 */

#include <iostream>

namespace workspace {

namespace internal {

struct ejection {
  bool exit = 0;
};

}  // namespace internal

/**
 * @brief eject from a try block, throw nullptr
 * @param arg output
 */
template <class Tp> void eject(Tp const &arg) {
  std::cout << arg << "\n";
  throw internal::ejection{};
}

void exit() { throw internal::ejection{true}; }

}  // namespace workspace
#line 11 "src/sys/iteration.hpp"

namespace workspace {

void main();

struct {
  // 1-indexed
  unsigned current{0};
  unsigned total{1};

  void read() { (std::cin >> total).ignore(); }

  int iterate() {
    static bool once = false;
    assert(!once);
    once = true;
    while (current++ < total) {
      try {
        main();
      } catch (internal::ejection const& status) {
        if (status.exit) break;
      }
    }
    return 0;
  }
} case_info;

}  // namespace workspace
#line 4 "test/aizu-online-judge/ITP1_3_B.test.cpp"

namespace workspace {

void main() {
  int x;
  std::cin >> x;
  if (!x) exit();
  std::cout << "Case " << case_info.current << ": " << x << std::endl;
}

}  // namespace workspace

int main() {
  workspace::case_info.total = -1;
  return workspace::case_info.iterate();
}
Back to top page