group_id
stringlengths
12
18
problem_description
stringlengths
85
3.02k
candidates
listlengths
3
20
aoj_1630_cpp
Expression Mining Consider an arithmetic expression built by combining single-digit positive integers with addition symbols + , multiplication symbols * , and parentheses ( ) , defined by the following grammar rules with the start symbol E . E ::= T | E '+' T T ::= F | T '*' F F ::= '1' | '2' | '3' | '4' | '5' | '6...
[ { "submission_id": "aoj_1630_10665435", "code_snippet": "// C++ includes used for precompiling -*- C++ -*-\n// Copyright (C) 2003-2013 Free Software Foundation, Inc.\n//\n// This file is part of the GNU ISO C++ Library. This library is free\n// software; you can redistribute it and/or modify it under the\n...
aoj_1629_cpp
Equilateral Triangular Fence Ms. Misumi owns an orchard along a straight road. Recently, wild boars have been witnessed strolling around the orchard aiming at pears, and she plans to construct a fence around many of the pear trees. The orchard contains n pear trees, whose locations are given by the two-dimensional Eucl...
[ { "submission_id": "aoj_1629_10852996", "code_snippet": "#include <cstdio>\n#include <cmath>\n#include <algorithm>\nconst int N = 1e6 + 7;\ndouble sq3 = sqrt(3.0);\nstruct Node {\n int x, y;\n double dx, dy;\n} p[N], left[N], right[N], l[N], r[N];\nint n, k;\nbool cmp1(const Node &a, const Node &b) {\n retu...
aoj_1632_cpp
Scores of Final Examination I am a junior high school teacher. The final examination has just finished, and I have all the students' scores of all the subjects. I want to know the highest total score among the students, but it is not an easy task as the student scores are listed separately for each subject. I would lik...
[ { "submission_id": "aoj_1632_10882956", "code_snippet": "#include <iostream>\n#include <vector>\n\ntemplate <typename T>\nclass matrix: public std::vector< std::vector<T> >\n{\npublic:\n\tmatrix(int m = 0, int n = 0, const T& v = T()):\n\t\tstd::vector< std::vector<T> >(m, std::vector<T>(n, v)) {}\n\tint ro...
aoj_1631_cpp
For Programming Excellence A countless number of skills are required to be an excellent programmer. Different skills have different importance degrees, and the total programming competence is measured by the sum of products of levels and importance degrees of his/her skills. In this summer season, you are plann...
[ { "submission_id": "aoj_1631_10853852", "code_snippet": "#include<bits/stdc++.h>\ntypedef long long int ll;\ntypedef unsigned long long int ull;\nconst ll BIG_NUM = 2e9;\nconst ll HUGE_NUM = 99999999999999999;\nconst ll MOD = 1e9+7;\nconst double EPS = 1e-9;\n\nusing namespace std;\n\nconst int SIZE = 100...
aoj_1633_cpp
On-Screen Keyboard You are to input a string with an OSK (on-screen keyboard). A remote control with five buttons, four arrows and an OK (Fig. B-1), is used for the OSK. Find the minimum number of button presses required to input a given string with the given OSK. Fig. B-1 Remote control Fig. B-2 An on-...
[ { "submission_id": "aoj_1633_10897969", "code_snippet": "/*\n * author : cellul4r\n */\n#include<bits/stdc++.h>\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair<int, int> pi;\ntypedef pair<ll,ll> pl;\ntypedef pair<ld,ld> pd;\n#define all(x) x.begin(), x.end()\nconst ch...
aoj_1638_cpp
Let's Move Tiles! You have a framed square board forming a grid of square cells. Each of the cells is either empty or with a square tile fitting in the cell engraved with a Roman character. You can tilt the board to one of four directions, away from you, toward you, to the left, or to the right, making all the tiles sl...
[ { "submission_id": "aoj_1638_10865908", "code_snippet": "#include<bits/stdc++.h>\nusing namespace std;\n\n#define ALL(v) begin(v),end(v)\n#define REP(i,n) for(int i=0;i<(n);++i)\n#define RREP(i,n) for(int i=(n)-1;i>=0;--i)\n\ntypedef long long LL;\ntypedef vector<int> vint;\n\nconst int targets[4][9] = {\n\...
aoj_1635_cpp
Tally Counters A number of tally counters are placed in a row. Pushing the button on a counter will increment the displayed value by one, or, when the value is already the maximum, it goes down to one. All the counters are of the same model with the same maximum value. Fig. D-1 Tally Counters Starting from the values i...
[ { "submission_id": "aoj_1635_10898275", "code_snippet": "/*\n * author : cellul4r\n */\n#include<bits/stdc++.h>\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair<int, int> pi;\ntypedef pair<ll,ll> pl;\ntypedef pair<ld,ld> pd;\n#define all(x) x.begin(), x.end()\nconst ch...
aoj_1634_cpp
Balance Scale You, an experimental chemist, have a balance scale and a kit of weights for measuring weights of powder chemicals. For work efficiency, a single use of the balance scale should be enough for measurement of each amount. You can use any number of weights at a time, placing them either on the ba...
[ { "submission_id": "aoj_1634_10898057", "code_snippet": "/*\n * author : cellul4r\n */\n#include<bits/stdc++.h>\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair<int, int> pi;\ntypedef pair<ll,ll> pl;\ntypedef pair<ld,ld> pd;\n#define all(x) x.begin(), x.end()\nconst ch...
aoj_1636_cpp
Cube Surface Puzzle Given a set of six pieces, “Cube Surface Puzzle” is to construct a hollow cube with filled surface. Pieces of a puzzle is made of a number of small unit cubes laid grid-aligned on a plane. For a puzzle constructing a cube of its side length n , unit cubes are on either of the following two areas. Co...
[ { "submission_id": "aoj_1636_10851082", "code_snippet": "#include <bits/stdc++.h>\n\nusing namespace std;\ntypedef long long ll;\n\nstruct jie{\n char s[10][10][10];\n}mp[7];\nchar a[15][15][15];\nint n;\nint flag,us[15];\nvoid dfs(int m){\n if(m>6){\n flag=1;\n return;\n }\n for(i...
aoj_1639_cpp
Addition on Convex Polygons Mr. Convexman likes convex polygons very much. During his study on convex polygons, he has come up with the following elegant addition on convex polygons. The sum of two points in the xy -plane, ( x 1 , y 1 ) and ( x 2 , y 2 ) is defined as ( x 1 + x 2 , y 1 + y 2 ). A polygon is treated as...
[ { "submission_id": "aoj_1639_10849688", "code_snippet": "#include <iostream>\n#include <vector>\n#include <algorithm>\n#include <utility>\nusing namespace std;\n\ntypedef long long LL;\ntypedef pair<LL,LL> pll;\n\npll add(const pll &a, const pll &b){\n\treturn pll(a.first + b.first, a.second + b.second);\n}...
aoj_1637_cpp
Flipping Colors You are given an undirected complete graph. Every pair of the nodes in the graph is connected by an edge, colored either red or black. Each edge is associated with an integer value called penalty. By repeating certain operations on the given graph, a “spanning tree” should be formed with only the red ed...
[ { "submission_id": "aoj_1637_10853073", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\n\ntypedef long long ll;\n#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)\n#define ALL(v) (v).begin(),(v).end()\n#define CLR(t,v) memset(t,(v),sizeof(t))\ntemplate<class T1,class T2>ostream& operator<<...
aoj_1646_cpp
Avoiding Three Cs You are a member of ICPC Company, and planning to place seats in the new office. Your task is to place as many seats as possible in the room while satisfying the conditions for avoiding three Cs . You decided to solve the problem through simulation on a grid. In the simulation, the room is...
[ { "submission_id": "aoj_1646_9417671", "code_snippet": "#include<bits/stdc++.h>\nusing namespace std;\n\n#include <algorithm>\n#include <cassert>\n#include <limits>\n#include <queue>\n#include <vector>\n\nnamespace atcoder {\n\ntemplate <class Cap, class Cost> struct mcf_graph {\n public:\n mcf_graph() ...
aoj_1643_cpp
Icpcan Alphabet Figure D-1 A picture of two expressions engraved on a stone wall. Research on the civilization of old kingdom of Icpca has been carried out at the Investigation Center for Prehistoric Civilization (ICPC). Their recent excavation found two expressions engraved on a stone wall at the ruins of Icpca. The e...
[ { "submission_id": "aoj_1643_10881117", "code_snippet": "#include <bits/stdc++.h>\n\nusing namespace std;\nusing ll = long long;\n\n// clang-format off\n\nint n;\nstring a;\nstring S, T;\n\nchar val(const string& P, int& r, char tchar, int mask) {\n ++r;\n if (P[r-1]==tchar) return 1;\n int idx=P[r...
aoj_1642_cpp
Luggage Mr. Yokohama is estimating the delivery fare for a number of luggage pieces. The fare for a piece is determined by its width w , depth d and height h , each rounded up to an integer. The fare is proportional to the sum of them. The list of the luggage pieces is at hand, but the list has the product w × d × h f...
[ { "submission_id": "aoj_1642_10849119", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\nconst int N=4e7+3;\nbool isComposite[N];\nlong long primes[N], sz;\nvoid sieve() { // save the all primes till N in linear time\n isComposite[0] = isComposite[1] = true;\n for (int i = 2; i < N; +...
aoj_1644_cpp
Keima You are given a set of points aligned in a grid of N rows and M columns. Each of the points is named P i , j with its row number i (1 ≤ i ≤ N ) and its column number j (1 ≤ j ≤ M ). Each point is colored either white or black. Your task is to compute the number of subsets T of white points satisfying the followin...
[ { "submission_id": "aoj_1644_10666042", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\n\ntemplate<int MOD>\nstruct modint {\n modint() : x(0) {}\n modint(long long v) {\n long long y = v % m();\n if (y < 0) y += m();\n x = (unsigned int)(y);\n }\n static mo...
aoj_1645_cpp
Evacuation Site The council of your home city decided to build a public evacuation site to prepare for natural disasters. The evacuation site is desired to be built at a location reachable from as many locations across the city as possible, even when many road segments are closed due to a natural disaster. Given the ro...
[ { "submission_id": "aoj_1645_10672181", "code_snippet": "#line 1 \"library/Template/template.hpp\"\n#include <bits/stdc++.h>\nusing namespace std;\n\n#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)\n#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)\n#define ALL(v) (v).begin()...
aoj_1649_cpp
Hundred-Cell Calculation Puzzles The hundred-cell calculation is a kind of calculation training. In hundred-cell calculation, a sheet with ten by ten empty cells is given. Numbers, 0 through 9, are written on the top of the ten columns in an arbitrary order. 0 through 9 are also written at the left of the ten rows in ...
[ { "submission_id": "aoj_1649_10643103", "code_snippet": "#include <bits/stdc++.h>\n#define ll long long\n#define ld long double\nusing namespace std;\n\n\nll detA(vector<vector<ld>> M, ll n){\n ll t = 1;\n ll det = 1;\n for (int i = 1; i < n; i++){\n if (M[i][i] == 0){\n for (int ...
aoj_1647_cpp
Idealistic Canister The Ideally Compact Packaging Canisters (ICPC) corporation is a package manufacturer specialized in canisters (cylindrical containers), designing and manufacturing canisters satisfying clients' demands. The corporation has taken an order of a canister to pack two different products together. Both pr...
[ { "submission_id": "aoj_1647_9994054", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\n\nclass point2d {\npublic:\n double x, y;\n point2d() : x(0.0), y(0.0) {};\n point2d(double x_, double y_) : x(x_), y(y_) {};\n point2d& operator+=(const point2d& p) { x += p.x; y += p.y; retu...
aoj_1650_cpp
Tree Transformation Puzzle Let's get started with a puzzle! First, you are given an arithmetic expression, which solely consists of integers, operator symbols + and − , and parentheses. (4−1)−(2+3)−(5+6) is an example of such an expression. As is well known, the structure of an arithmetic expression is naturally repres...
[ { "submission_id": "aoj_1650_10845127", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\n\n//https://onlinejudge.u-aizu.ac.jp/services/ice/?problemId=1650\n//模擬解答を参考\n\nconst int INF = 1e9; //非常に大きな値\n\nstruct Node {\n char op; // '+', '-', or '@' (葉ノード)\n int val; // if op == '@'\n ...
aoj_1651_cpp
Handing out Balloons Each time an ICPC participant team has successfully solved a problem at the competition site, a balloon of a color specific to that problem is delivered to that team. You had thus prepared enough number of balloons of various colors for the case when all the teams solved all the problems, but many...
[ { "submission_id": "aoj_1651_10684431", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\nusing B = bitset<2501>;\n\nvoid solve(int n) {\n vector<int> a(n);\n int sm = 0;\n for (auto &i: a) {\n cin >> i;\n sm += i;\n }\n vector<B> dp(2501);\n dp[0][0] = 1;\n ...
aoj_1652_cpp
Time is Money The city of ICPC has made excessive pedestrian separation, making transportation in the city quite complicated. Citizens of the ICPC city thus have big concern on efficient transportation to save time. The residents are eager to reach their destinations as fast as possible by repeatin...
[ { "submission_id": "aoj_1652_10675436", "code_snippet": "#define _USE_MATH_DEFINES\n#include<bits/stdc++.h>\nusing namespace std;\nusing ll = long long;\nusing ld = long double;\nusing H = pair<ll, ll>;\nusing P = pair<ll, H>;\nusing vi = vector<int>;\nusing vl = vector<ll>;\n#define all(a) (a).begin(), (a)...
aoj_1660_cpp
Problem E Village of Lore Icpca village, said to lie in a deep jungle, is known by strange, contradictory lore. Some say there lies a epitome of happiness while others say it is a terrible fortress of horror. An old soothsayer, who is a precious source of information, reported that Icpca village has a rectangular form ...
[ { "submission_id": "aoj_1660_10676160", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\n\n/*\n#include <atcoder/all>\nusing namespace atcoder;\nusing mint = modint998244353;\n// using mint = modint1000000007;\n//*/\n\nusing ll = long long;\nusing i128 = __int128_t;\nusing pll = pair<ll, ll>...
aoj_1653_cpp
Princess' Perfectionism The princess has n spies, and she is planning to assign exactly n tasks to them. Skills of the spies constrain the eligibilities for the tasks. The princess is a perfectionist, and she is not satisfied unless each spy is assigned exactly one task, and each task is assigned to exactly one spy. Fo...
[ { "submission_id": "aoj_1653_10625084", "code_snippet": "#line 2 \"/home/nixos/workspace/CompPro-Make/library/KowerKoint/stl-expansion.hpp\"\n#include <bits/stdc++.h>\n\ntemplate <typename T1, typename T2>\nstd::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {\n is >> p.first >> p.second;\n ...
aoj_1663_cpp
Problem H Artist in Agony You, an artist, prepared a sufficient number of balls and also strings to link them for your artwork. Balls are to be given sequential numbers eventually, but only one of the balls is given number 1 at the beginning. No other balls are numbered and no balls are linked to any other balls yet. ...
[ { "submission_id": "aoj_1663_10569153", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\nusing ll = long long;\nusing ull = unsigned long long;\nusing uint = unsigned int;\n#define rep(i, n) for (int i = 0; i < n; i++)\n#define all(v) v.begin(), v.end()\ntemplate <class T, class U>\ninline b...
aoj_1662_cpp
Problem G Keep in Touch Two agents A and B, known as a great combination, are conducting the infiltration mission to a secret base. Due to the strict security of the base, two agents have decided to follow the prechecked safe infiltration routes R A and R B , respectively. Each infiltration route is a two-dimensional p...
[ { "submission_id": "aoj_1662_10203399", "code_snippet": "#include <iostream>\n#include <vector>\n#include <math.h>\n#include <algorithm>\n#include <set>\n#include <map>\n\nusing namespace std;\nusing ld = long double;\n\nld eps = 1e-10;\nld INF = 1e9;\n\nstruct point {\n\tld x, y;\n\tpoint() {\n\t\tx = 0;\n...
aoj_1657_cpp
Problem B Leave No One Behind A card game similar to Old Maid is played by n players P 1 , ..., and P n , sitting clockwise in this order. For this game, n pairs of cards numbered 1 through n are used. Each player has two cards at hand to start with. First, any player who has a pair of cards with the same number di...
[ { "submission_id": "aoj_1657_10684192", "code_snippet": "#include <iostream>\n#include <iomanip>\n#include <vector>\n#include <math.h>\n#include <queue>\n#include <deque>\n#include <map>\n#include <set>\n#include <algorithm>\n#include <functional>\n#include <cassert>\nusing namespace std;\n#define rep(i, n)...
aoj_1666_cpp
Problem C Changing the Sitting Arrangement You are the teacher of a class of n 2 pupils at an elementary school. Seats in the classroom are set up in a square shape of n rows (row 1 through row n ) by n columns (column 1 through column n ). You are planning a change in the sitting arrangement. In order for your pupils ...
[ { "submission_id": "aoj_1666_10669785", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\nusing ll = long long;\n#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)\n#define rrep(i, s, t) for(ll i = (ll)(t) - 1; i >= (ll)(s); i--)\n#define all(x) begin(x), end(x)\n#define rall(x) rbegin(x),...
aoj_1661_cpp
Problem F Trim It Step by Step The intelligence agency of the Kingdom uses a unique encryption method; a nonempty message consisting only of lowercase letters is encrypted into an expression <expr> complying with the grammar described by the following BNF. <expr> ::= <char> | <expr><expr> | ?( <expr> ) <char> ::= a | b...
[ { "submission_id": "aoj_1661_10483298", "code_snippet": "#include <bits/stdc++.h>\n\nusing namespace std;\n\nvoid solve() {\n string s; cin >> s;\n int n = ssize(s);\n vector<int> closing(n, -1);\n stack<int> stk;\n for(int i = 0; i < n; i++) {\n if(s[i] == '?') stk.push(i);\n e...
aoj_1658_cpp
Problem C Training Schedule for ICPC With little time remaining until ICPC, you decided to reschedule your training plan. As maintaining both mental and physical vitality is important, you decided to spend n days of the remaining n + m days for training, and m days for repose. The question is which days should be use...
[ { "submission_id": "aoj_1658_10684472", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\nint main(){\n long long n,m;\n vector<long long> lastans;\n while(true){\n cin >> n >> m;\n if(n==0&&m==0){\n break;\n }\n long long ans=n*n-m*m;\n ...
aoj_1659_cpp
Problem D Audience Queue You are working as a staff member at a concert venue, organizing the audience queue. Everyone in the queue holds one ticket with a seat number printed. The seat numbers are integers from 1 to n without duplicates. Since this is a very popular concert, all the seats are reserved and exactly n p...
[ { "submission_id": "aoj_1659_10676345", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\nusing ll = long long;\nconst ll mod = 998244353;\n\nll powmod(ll a, ll b) {\n ll ret = 1;\n ll k = a;\n while (b) {\n if (b & 1) {\n ret *= k;\n ret %= mod;\n ...
aoj_1673_cpp
Problem B Overtaking Two athletes run a long-distance race, but the race is different from usual athletics events. They run for a predetermined duration, and the one who runs longer will be the winner. At every minute after the start, the distances both runners ran in the previous one minute are recorded. You are expec...
[ { "submission_id": "aoj_1673_9694077", "code_snippet": "#include <bits/stdc++.h>\n#define rep(i, n) for (int i = 0; i < (int)(n); i++)\nusing namespace std;\n#undef long\n#define long long long\n#define vec vector\nvoid solve()\n{\n int n;\n cin >> n;\n if (n == 0)\n exit(0);\n vec<int> a...
aoj_1665_cpp
Problem B Amidakuji Amidakuji is a method of lottery popular in East Asia. It is often used when a number of gifts are distributed to people or when a number of tasks are assigned. Figure B-1: An example of amidakuji Figure B-1 shows an example of amidakuji, which corresponds to the first dataset of Sample Input. A num...
[ { "submission_id": "aoj_1665_10845715", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\nusing ll = long long;\n\nint main(){\n while(true){\n int n, m, p, q;\n cin >> n >> m >> p >> q;\n if(!n) break;\n\n vector<int> amida(m);\n for(auto& i:amida) cin >> i;\n\n int save_p...
aoj_1667_cpp
Problem D Efficient Problem Set You are planning a problem set for the upcoming programming contest. The problem set should consist of one or more problems each allocated with a certain amount of points, which is a positive integer. The score of each contestant is the sum of the points of the problems that the contesta...
[ { "submission_id": "aoj_1667_10824752", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\n\n#define MAXS 100 // 最大データセット数\n#define MAXN 100 // 最大満点\n\n\n\nint solve(int n, const string& s) {\n for (int k = 1; k <= n; ++k) {\n bool found = false;\n vector<int> tmp;\n\n ...
aoj_1669_cpp
Problem F Villa of Emblem Shape The princess has a vast private estate. She has decided to build a new villa there. According to her creative request, the ground floor outline of the main house of the villa must be derived from the emblem of the royal family. The emblem is a simple polygon. Four examples are shown in F...
[ { "submission_id": "aoj_1669_10958528", "code_snippet": "#define _CRT_SECURE_NO_WARNINGS\n#include <iostream>\n#include <algorithm>\n#include <cmath>\n#include <vector>\ntypedef long long ll;\ntypedef double ld;\ninline int sign(const ll& x) { return x < 0 ? -1 : !!x; }\n\nint N;\nstruct Pos {\n\tint x, y, ...
aoj_1670_cpp
Problem G Fair Deal of Dice You are serving as the gamemaster of a two-player game in which several cubic dice are used. Each face of the dice has a number on it. Unlike conventional dice, the numbers are not necessarily one through six. Before starting a game, you select a predefined number of dice from the set of dic...
[ { "submission_id": "aoj_1670_10567721", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\nusing ll = long long;\n#define rep(i, n) for (int i = 0; i < n; i++)\n#define all(v) v.begin(), v.end()\ntemplate <class T, class U>\ninline bool chmax(T& a, U b) {\n if (a < b) {\n a = b;\n ...
aoj_1678_cpp
Problem G Two Sets of Cards As an entertainment after the programming contest, you hold a game event for the participants. Two sets of cards, red ones and blue ones, are used in the game. Both of the two sets have the same number of cards as the number of the participants, and each card has one integer written on it. I...
[ { "submission_id": "aoj_1678_10781175", "code_snippet": "#include<bits/stdc++.h>\nusing namespace std;\nint main()\n{\n\tint n;\n\tcin>>n;\n//\tn=10;\n\twhile(n)\n\t{\n//\t\tvector<int>a0(n+1),b0;\n//\t\tfor(int i=1;i<=n;i++)a0[i]=rand()%151-75;\n//\t\tb0=a0;\n//\t\tfor(int i=n;i>1;i--)\n//\t\t\tswap(b0[i],...
aoj_1668_cpp
Problem E Tampered Records In ancient times, the International Collegiate Puzzle Contest (ICPC) was held annually. Each of the annual contests consisted of two rounds: the morning round and the afternoon round. In both of the two rounds, the participants posed one puzzle made on their own to all the other participa...
[ { "submission_id": "aoj_1668_10683499", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\n\n#include <atcoder/all>\nusing namespace atcoder;\n\nbool solve() {\n int N;\n cin >> N;\n if(N == 0) return false;\n using P = pair<int, int>;\n const P MINF = P{0, -1};\n vector<P> d...
aoj_1677_cpp
Problem F Billiards You are challenging a game with prizes, which is similar to billiards. This game uses a kind of billiard table, several balls of the same size, and a prize coin. The top of the table has a flat rectangular cloth-covered area bounded by elastic bumpers, called cushions. The balls can move...
[ { "submission_id": "aoj_1677_10850999", "code_snippet": "// I made some changes to the original code.\n\n// #include<bits/stdc++.h>\n#include<iostream>\n#include<algorithm>\n#include<set>\n#include<tuple>\n#include<vector>\n#include<utility>\nusing namespace std;\ntypedef long long ll;\ntypedef pair<ll,ll> ...
aoj_1674_cpp
Problem C Honeycomb Distance A plane is tiled completely with regular hexagons. Each hexagon is called a cell. You can move in one step from a cell to one of its adjacent cells that share an edge. You want to know the minimum number of steps to move from the central cell to the specified cell. Each cell is specified ...
[ { "submission_id": "aoj_1674_10687657", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\nusing ll = long long;\nusing pint = pair<int,int>;\nusing pll = pair<long long, long long>;\n\n#define rrep1(a) for(ll i = (ll)(a-1); i >= (ll)0 ; i--)\n#define rrep2(i, a) for(ll i = (ll)...
aoj_1675_cpp
Problem D A Bug That's Not a Pill Bug A bug that looks like a pill bug is walking on a plane. A Cartesian coordinate system is defined on the plane, in which its x- axis is directed from west to east, while its y- axis is directed from south to north. The bug is initially at a lattice point (a point where both the x- a...
[ { "submission_id": "aoj_1675_10681419", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\nusing ll = long long;\n#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)\n#define rrep(i, s, t) for(ll i = (ll)(t) - 1; i >= (ll)(s); i--)\n#define all(x) begin(x), end(x)\n#define rall(x) rbegin(x),...
aoj_2004_cpp
Data Center on Fire 今から少し未来の話である.高密度記憶および長期保存可能である記録デバイスが開発されてきたが,コンテンツが生み出される速度が異常なほどに速かったため,データセンターを設立した.データセンターを設立した当初は小さな建物だったが,増え続けるデータにあわせて何度も拡張工事をしたため,性能の異なるエレベータを何基も持つこととなった. ところが,データセンターで火災が発生した.火は一定時間だけ経過すると上の階ないし下の階に燃え広がる.また,火がついてから一定時間だけ経過するとその階は焼失してしまう.そこでエレベータを使ってデバイスを運び出すこととした.このエレベータは耐火性能が完璧であるため,階の焼失に関...
[ { "submission_id": "aoj_2004_9173332", "code_snippet": "#include<bits/stdc++.h>\nusing namespace std;\ntypedef long long int ll;\ntypedef unsigned long long int ull;\n#define chmin(x,y) x = min(x,y)\n#define chmax(x,y) x = max(x,y)\n#define BIG_NUM 2000000000\n#define HUGE_NUM 4000000000000000000 //オーバーフローに...
aoj_2002_cpp
X-Ray Screening System これは 20XX 年の話である.再生発電網による安定したエネルギー供給,および液化合成燃料の発明によって航空旅客数は鰻登りに増加した.しかし,航空機によるテロリズムの脅威は依然として存在するため,高速でかつ高い信頼性をもつ自動手荷物検査システムの重要性が高まっている.検査官が全部の荷物を調べることは実際問題として困難であることから,自動検査において疑わしいと判断された手荷物だけを検査官で改めて調べるという仕組みを整えたいわけである. 航空機業界からの要請を受け,国際客室保護会社(International Cabin Protection Company)では,新たな自動検査システムを開...
[ { "submission_id": "aoj_2002_10848556", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\n\nint main()\n{\n\tint N, H, W;\n\tcin >> N;\n\twhile (N--) {\n\t\tcin >> H >> W;\n\t\tvector<int> used(26), xma(26), xmi(26, 100), yma(26), ymi(26, 100);\n\t\tvector<vector<char>> a(H, vector<char>(W));...
aoj_2001_cpp
Amida, the City of Miracle 奇跡の都市アミダ(Amida, the City of Miracle)の市長は他の市のように選挙で選ぶのではない.かつて長い政権闘争と天変地異により疲弊したこの都市は,候補者全員を公平に選び,かつ幸運の星の下に生まれた者を市長にするために,候補者全員の運命をくじにゆだねることにしたのである.後にあみだくじと呼ばれるくじである. 選挙は以下のように行われる.候補者数と同数の長い縦線が引かれ,さらにいくつかの横線がそこに引かれる.横線は隣接した縦線の途中同士を結ぶように引かれる.いずれかの縦線の下には「当選」と書かれている.どの縦線が当選であるかは候補者からわからないように隠される...
[ { "submission_id": "aoj_2001_10849592", "code_snippet": "#include \"bits/stdc++.h\"\n\nusing namespace std;\n#define FOR(i,s,t) for (int i = s; i < t; i++)\n#define SZ(x) (int)x.size()\nusing LL = long long; using ll = LL;\nusing VI = vector<int>; using VL = vector<LL>;\nconst LL INF = 1e9; const LL LINF = ...
aoj_2007_cpp
Problem B: Make Purse Light Mr. Bill は店で買い物をしている。 彼の財布にはいくらかの硬貨(10 円玉、50 円玉、100 円玉、500 円玉)が入っているが、彼は今この小銭をできるだけ消費しようとしている。 つまり、適切な枚数の硬貨によって品物の代金を払うことで、釣り銭を受け取った後における硬貨の合計枚数を最小にしようとしている。 幸いなことに、この店の店員はとても律儀かつ親切であるため、釣り銭は常に最適な方法で渡される。 したがって、例えば 1 枚の 500 円玉の代わりに 5 枚の 100 円玉が渡されるようなことはない。 また、例えば 10 円玉を 5 枚出して、50 円玉を釣り銭として受...
[ { "submission_id": "aoj_2007_10852642", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\n\nusing ll = long long;\n\nint main() {\n int n;\n int q = 0;\n while(cin >> n, n) {\n if(q != 0) {\n cout << endl;\n }\n q++;\n int a, b, c, d;\n c...
aoj_2005_cpp
Water Pipe Construction 21XX 年,ついに人類は火星への移住計画を開始させた.火星への移住第一陣に選抜されたあなたは,火星行政中央局(the Administrative Center of Mars)に配属され,火星で起こる様々な問題に対処している.行政中央局の目下の最大の問題は自立した需要供給サイクルの確保である.月からの援助物資が届くまでには数ヶ月単位の時間がかかるため,基本的には火星内の需要は火星内で解決する必要がある.それに加えて,循環システムを確立するまでは資源を極力節約することが求められる. 行政中央局は極地にある氷の採掘を開始した.太陽光でこれを溶かし,水として個々の基地に供給することが最終...
[ { "submission_id": "aoj_2005_10852719", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\n\nusing VS = vector<string>; using LL = long long;\nusing VI = vector<int>; using VVI = vector<VI>;\nusing PII = pair<int, int>; using PLL = pair<LL, LL>;\nusing VL = vector<LL>; using ...
aoj_2003_cpp
Railroad Conflict Nate U. Smith は大都市圏の鉄道会社を経営している.この大都市圏には,彼の鉄道会社以外にライバルの鉄道会社がある.2 社は互いに競合関係にある. この大都市圏では,列車の運行を容易にするため,全ての路線は両端の駅を結んだ線分を経路としている.また,踏切等の設置をさけるため,全ての路線は高架または地下に敷設されている.既存路線は,全線にわたって高架を走るか,または全線にわたって地下を走るかのいずれかである. ところで,最近,この大都市圏にある 2 つの街区 A,B がさかんに開発されていることから,Nate の会社ではこれらの街区の間に新しい路線を設けることを決断した.この新路線は,従来...
[ { "submission_id": "aoj_2003_10851339", "code_snippet": "#define _USE_MATH_DEFIMES\n#include <algorithm>\n#include <array>\n#include <bitset>\n#include <cassert>\n#include <cctype>\n#include <climits>\n#include <clocale>\n#include <cmath>\n#include <complex>\n#include <cstdio>\n#include <cstdlib>\n#include ...
aoj_2009_cpp
Problem D: Area Separation Mr. Yamada Springfield Tanaka は、国家区画整理事業局局長補佐代理という大任を任されていた。 現在、彼の国は大規模な区画整理の最中であり、この区画整理をスムーズに終わらせることができたならば彼の昇進は間違いなしであるとされている。 ところが、そんな彼の出世を快く思わない者も多くいるのだ。 そんな人間の 1 人に、Mr.Sato Seabreeze Suzuki がいた。 彼は、ことあるごとに Mr. Yamada の足を引っ張ろうと画策してきた。 今回も Mr. Sato は足を引っ張るために、実際の区画整理を担当している組織に圧力をかけて...
[ { "submission_id": "aoj_2009_10854083", "code_snippet": "#include<bits/stdc++.h>\nusing namespace std;\nusing ll = long long;\n\ntypedef complex<double> P;\nconst double EPS = 1e-12;\n#define EQ(n,m) (abs((n)-(m)) < EPS)\n\ndouble cross(P a, P b) {\n\treturn (conj(a)*b).imag();\n}\n\nP crosspointLL(P a1, P ...
aoj_2008_cpp
Problem C: Dragon Fantasy 永遠に続くと思われていた平和は突然終わりを告げた。 はるか昔に封印されていた魔王がついに復活を遂げたのである。 だが、今まさに世界が闇に覆われようとしているとき、1 人の勇者が現れた。 そしてその勇者は、世界各地に散らばっている伝説のクリスタルを集める旅に出た。 伝説によると、全てのクリスタルを集めることができたならば、どのような願いでもかなえられるという伝説の龍神を呼び出すことができると伝えられている。 その龍神の力を借りれば魔王を倒すことも可能なはずだ。 クリスタルは世界各地に散らばっている。 勇者はそれらを 1 つずつ、自らの手で集めていく必要がある。 なぜなら、勇者以外の者...
[ { "submission_id": "aoj_2008_9626361", "code_snippet": "#include<bits/stdc++.h>\nusing namespace std;\ntypedef long double ld;\n#define FOR(i,l,r) for(auto i=l;i<r;i++)\n#define REP(i,n) FOR(i,0,n)\n#define F first\n#define S second\nint main(){\n while(1){\n int N;cin>>N;\n vector<pair<int...
aoj_2010_cpp
Problem E: Poor Mail Forwarding Masa 君が住んでいる地域の郵便システムは少々変わっている。 この地域では、各々の郵便局に対して 1 から順に連続した異なる番号がつけられており、ある郵便局に届けられた郵便物は、その郵便局からいくつかの郵便局を経由して目的の郵便局に届けられる。 郵便物の「転送」は、特定の郵便局の間でしか行われない。 ただし、転送が行われる郵便局同士の間では、転送は双方向に行われる。 ある郵便局から宛先まで郵便物を転送するための経路が複数存在する場合は、 宛先までの距離が最短となるような経路を使用する。 したがって、転送先はそのような最短経路における次の郵便局となる。...
[ { "submission_id": "aoj_2010_10204478", "code_snippet": "// AOJ #2010\n// Poor Mail Forwarding 2025.2.8\n\n#include <bits/stdc++.h>\nusing namespace std;\nusing ll = long long;\n const int INF = 1000000000;\n \nstruct Mail {\n int src, dest;\n ll start_time;\n string label;\n ll delivered_time;\...
aoj_2011_cpp
Problem F: Gather the Maps! はるか昔、八尾氏が残したとされる伝説の秘宝が八王子のどこかに眠っているという。 その在処を示すとされる宝の地図は、いくつかの断片に分割された状態で、八尾氏の n 人の子孫達によって受け継がれている。 今、八尾氏の子孫達は協力してその秘宝を手に入れようとしていた。 ところが、秘宝の在処を指し示す宝の地図の一部分だけでは秘宝を見つけることができない。 そこで、八尾氏の子孫達は全員で集まって地図を 1 ヶ所に集めようとした。 ところが、いざ実行に移そうとしてもなかなか予定が合わずに集まることができない。 しかしこの秘宝に関する情報は、一族において秘密裏に伝えられてきた貴重な情報...
[ { "submission_id": "aoj_2011_10853823", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\n\nint main()\n{\n\tint n;\n\twhile (cin >> n, n) {\n\t\tvector<vector<int>> v(31);\n\t\tfor (int i = 0, f; i < n; i++) {\n\t\t\tcin >> f;\n\t\t\tfor (int j = 0, d; j < f; j++) {\n\t\t\t\tcin >> d;\n\t\t\...
aoj_2013_cpp
Osaki 大崎 English text is not available in this practice contest. 山手線は東京 23 区内に敷設されている環状鉄道路線である.総路線距離は 34.5km であり,1 周にはおよそ 1 時間を要する.駅は全部で 29 駅存在する.ラインカラーはウグイス色である.ピーク時の混雑率は 200% を超え,日本の鉄道路線の中で最も混雑している路線の 1 つである.最も混雑する時間帯では 3 分に 1 本の列車が走っており,東京に初めて来た人々はその光景に驚くものである. 鉄子さんは山手線を愛してやまない生粋の鉄道好きである.ある日,彼女は愛読書である JR 時刻表を読みながら次の...
[ { "submission_id": "aoj_2013_11060394", "code_snippet": "#include <bits/stdc++.h>\n\nusing namespace std;\nusing ll = long long;\n#define rep(i, n) for (int i = 0; i < n; ++i)\n\nint time_to_int(string s) {\n int h = stoi(s.substr(0, 2));\n int m = stoi(s.substr(3, 2));\n int sec = stoi(s.substr(6,...
aoj_2014_cpp
Surrounding Area 土地囲い English text is not available in this practice contest. ある 2 人の不動産屋が,客船に乗って南の島に向かっていた.青い空,さわやかな風….2 人は他の乗客とともに船旅を楽しんでいた.ところが,ある日突然発生した竜巻によって客船が沈んでしまった.他の乗客は救助隊によって救助されたが,どういうわけかこの 2 人だけ見落とされてしまった.数日の漂流の後,彼らはある無人島に流れ着いた.この無人島は長方形であり,以下の図のように格子に区切られていた. 図 C-1: 無人島の形状 彼らはとても欲深かったので,助けを呼ぶことではなく,この無人島の...
[ { "submission_id": "aoj_2014_10588904", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\n\nbool solve() {\n int H, W;\n cin >> W >> H;\n if (H == 0 && W == 0) return false;\n vector<string> S(H);\n for (int i = 0; i < H; i++) cin >> S[i];\n int D[5] = {0, 1, 0, -1, 0};\n ...
aoj_2012_cpp
Space Coconut Crab 宇宙ヤシガニ English text is not available in this practice contest. ケン・マリンブルーは,宇宙ヤシガニを求めて全銀河を旅するスペースハンターである.宇宙ヤシガニは,宇宙最大とされる甲殻類であり,成長後の体長は 400 メートル以上,足を広げれば 1,000 メートル以上にもなると言われている.既に多数の人々が宇宙ヤシガニを目撃しているが,誰一人として捕らえることに成功していない. ケンは,長期間の調査によって,宇宙ヤシガニの生態に関する重要な事実を解明した.宇宙ヤシガニは,驚くべきことに,相転移航法と呼ばれる最新のワープ技術と同等のことを...
[ { "submission_id": "aoj_2012_10848222", "code_snippet": "#include<bits/stdc++.h>\nusing namespace std;\n#define FOR(i,s,t) for(int i = s; i < t ; i++)\nusing LL = long long; using VL = vector<LL>;\ntemplate<class T> using V = vector<T>; template<class T> using VV = V<V<T>>;\nconst LL LINF = 1e18;\n\nvoid so...
aoj_2015_cpp
Square Route スクウェア・ルート English text is not available in this practice contest. このたび新しい豪邸を建てることを決めた大富豪の品田氏は,どの街に新邸を建てようかと悩んでいる.実は,品田氏は正方形がとても好きという変わった人物であり,そのため少しでも正方形の多い街に住みたいと思っている. 品田氏は,碁盤目状に道路の整備された街の一覧を手に入れて,それぞれの街について,道路により形作られる正方形の個数を数えることにした.ところが,道と道の間隔は一定とは限らないため,手作業で正方形を数えるのは大変である.そこであなたには,碁盤目状の道路の情報が与えられたときに,...
[ { "submission_id": "aoj_2015_10848499", "code_snippet": "#include<bits/stdc++.h>\n\nusing namespace std;\n\nint main(){\n int n,m;\n while(cin>>n>>m,n){\n vector<int>h(n),w(m);\n for(int i=0;i<n;++i){\n cin>>h[i];\n }\n for(int i=0;i<m;++i){\n cin>>w[i...
aoj_2017_cpp
Karakuri Doll からくり人形 English text is not available in this practice contest. からくり人形師の JAG 氏は,長年の研究の果てに,伝統技術と最新技術を融合させたすばらしいお茶汲み人形の開発に成功した.このお茶汲み人形は,下の図のように格子に区切られた家の中で,台所(K)でお茶の入った湯飲みを乗せるとそれを主人(M)の居場所まで持っていき,主人が飲み終わった湯飲みを乗せると台所まで戻っていくという仕事をする.ただし,この人形は台所と主人の間の往復経路を自分で見つけられるほど賢くはない.使用者はこの人形にプログラムをあらかじめ入力して,人形がきちんと往復できるよ...
[ { "submission_id": "aoj_2017_9409644", "code_snippet": "#line 2 \"cp-library/src/cp-template.hpp\"\n#include <bits/stdc++.h>\nusing namespace std;\nusing ll = long long;\nusing ld = long double;\nusing uint = unsigned int;\nusing ull = unsigned long long;\nusing i32 = int;\nusing u32 = unsigned int;\nusing...
aoj_2016_cpp
Lifeguard in the Pool プールの監視員 English text is not available in this practice contest. Horton Moore はプールの監視員として働いている.彼が見回りのためにプールの縁を歩いていたところ,プールの中で一人の少女がおぼれていることに気づいた.もちろん,彼は直ちに救助に向かわなければならない.しかも,少女の身に何かあっては大変であるから,少しでも早く少女のもとにたどり着きたい. あなたの仕事は,プールの形状(頂点数が 3〜10 の凸多角形),地上および水中における監視員の単位距離あたりの移動時間,そして監視員と少女の初期位置が与えられたときに,監...
[ { "submission_id": "aoj_2016_10848573", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\n#define FOR(i,a,b) for (int i=(a);i<=(b);++i)\n#define ROF(i,a,b) for (int i=(a);i>=(b);--i)\n#define fi first\n#define se second\n#define pb push_back\n#define mp make_pair\n#define pDI pair<double,int>...
aoj_2019_cpp
Princess' Marriage お姫様の嫁入り English text is not available in this practice contest. ある貧乏な国のおてんばで勇敢なお姫様は,ギャンブルの配当がパリミュチュエル方式で決定される事を知ることにより,ギャンブルについて詳しくなった気がしてギャンブルでの勝利を確信した.その結果,今までよりも更に多額のお金をつぎ込み,国民が納めた税金をすべて失うほどの負けを喫してしまった.この事態を重く受け止めた王様は,お姫様を隣の国へ嫁がせることにした.こうすることにより,お姫様を日頃の行いを反省させ,同時に隣国との交友を深めて財政援助をしてもらおうと考えたからである. お姫...
[ { "submission_id": "aoj_2019_10731946", "code_snippet": "//問題:https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2015&lang=jp\n//判定:AC\n\n//学習コメント:\n//辺の長さが同じ正方形を同時に数える処理に少し手間取った。\n\n#include <iostream> \n#include <vector> \n#include <algorithm> \n#include <utility>\nusing namespace std;\n\nint Prin(...
aoj_2022_cpp
Princess, a Cryptanalyst お姫様の暗号解読 English text is not available in this practice contest. ある貧乏な国のおてんばで勇敢なお姫様は,お忍びで出かけた町である日本語で書かれた古文書を手に入れた.お姫様は日本語ができるため,さっそくこの古文書を読んでみた.すると,驚くべき事が分かった.この古文書は,古の秘宝の在処を示していたのである.ところが,秘宝の在処は暗号になっており,容易には分からないようになっていた.そこでお姫様は,従者であるあなたに暗号の解読を手伝うように命令を下した. あなたはお姫様を助けるため昼夜を問わず調査を行った.その結果,Shor...
[ { "submission_id": "aoj_2022_5538521", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\nconst int INF = 110;\nint main(){\n while (true){\n int N;\n cin >> N;\n if (N == 0){\n break;\n }\n vector<string> S(N);\n for (int i = 0; i < N; i++){\n cin >> S[i];\n }\...
aoj_2027_cpp
Problem E: Reading a Chord In this problem, you are required to write a program that enumerates all chord names for given tones. We suppose an ordinary scale that consists of the following 12 tones: C, C # , D, D # , E, F, F # , G, G # , A, A # , B Two adjacent tones are different by a half step; the right one is highe...
[ { "submission_id": "aoj_2027_3269182", "code_snippet": "#include \"bits/stdc++.h\"\n\n#pragma warning(disable:4996)\nusing namespace std;\nstring root_sts = \"C ,C#,D ,D#,E ,F ,F#,G ,G#,A ,A#,B \";\n\nint get_num(string name) {\n\n\tint k= root_sts.find(name);\n\tstring l= root_sts.substr(0,k);\n\treturn co...
aoj_2029_cpp
Problem I: Light The Room You are given plans of rooms of polygonal shapes. The walls of the rooms on the plans are placed parallel to either x -axis or y -axis. In addition, the walls are made of special materials so they reflect light from sources as mirrors do, but only once. In other words, the walls do not reflect...
[ { "submission_id": "aoj_2029_3168624", "code_snippet": "#include <iostream>\n#include <iomanip>\n#include <complex>\n#include <vector>\n#include <algorithm>\n#include <cmath>\n#include <array>\nusing namespace std;\nconst double EPS = 1e-6;\nconst double INF = 1e12;\nconst double PI = acos(-1);\n#define EQ(...
aoj_2023_cpp
Princess, a Strategist お姫様は戦略家 English text is not available in this practice contest. ある貧乏な国の勇敢なお姫様は,お城を抜け出して古の秘宝を手に入れる冒険に出かける算段をしている.ところが,古の秘宝の周囲は複数のガーディアンによって守られており,普通の方法では辿り着くことができない.そこで,お姫様は従者であるあなたを囮にし,ガーディアン達の注意を惹きつけている間に秘宝を取って来るという作戦を考えた.そのような事をされては命がいくつあっても足りない,しかしお姫様の命令に従わないわけにもいかない.そこで,まずあなたはあらかじめ偵察をし,どのように動...
[ { "submission_id": "aoj_2023_6005917", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\ntypedef long long ll;\ntemplate<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }\ntemplate<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return...
aoj_2021_cpp
Princess in Danger お姫様の危機 English text is not available in this practice contest. ある貧乏な国のおてんばで勇敢なお姫様が,政略結婚のため別の国に嫁ぐことになった.ところが,お姫様を亡き者としようとしている悪漢に嫁ぎ先への道中で襲われお姫様が大けがをしてしまい,近くの病院に搬送された.ところが,悪漢はお姫様は確実に亡き者とするため特殊な毒を使っていた.そのため,お姫様を助けるには本国から特別な薬と冷凍された肉親の血液を大急ぎで運ばなければならなくなった. この血液は冷凍状態で輸送されるのだが,鮮度を保つため,前回の冷凍から最大 M 分以内に血液冷凍施設で...
[ { "submission_id": "aoj_2021_10617724", "code_snippet": "#pragma GCC target(\"avx2\")\n#pragma GCC optimize(\"O3\")\n#pragma GCC optimize(\"unroll-loops\")\n\n// #ifndef ONLINE_JUDGE\n// #define _GLIBCXX_DEBUG // 配列外参照のエラー\n// #endif\n\n// スタンダードライブラリ\n#include <bits/stdc++.h>\nusing namespace std;\n\n// 型関...
aoj_2032_cpp
Problem C: Online Quizu System ICPC (Internet Contents Providing Company) is working on a killer game named Quiz Millionaire Attack. It is a quiz system played over the Internet. You are joining ICPC as an engineer, and you are responsible for designing a protocol between clients and the game server for this system. As...
[ { "submission_id": "aoj_2032_1354222", "code_snippet": "#include<cstdio>\n#include<cstdlib>\n#include<cstring>\n#include<cmath>\n#include<iostream>\n#include<string>\n#include<vector>\n#include<map>\n#include<set>\n#include<list>\n#include<queue>\n#include<deque>\n#include<algorithm>\n#include<numeric>\n#in...
aoj_2026_cpp
Problem D: Divisor is the Conqueror Divisor is the Conquerer is a solitaire card game. Although this simple game itself is a great way to pass one’s time, you, a programmer, always kill your time by programming. Your task is to write a computer program that automatically solves Divisor is the Conquerer games. Here is t...
[ { "submission_id": "aoj_2026_10848967", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\n\ntypedef long long ll;\nvector<int> cur;\n\nint cnt[14];\nbool rec(int n, int sum)\n{\n if(n == 0)\n return 1;\n\n for(int i = 1; i <= 13; i++){\n if(cnt[i] != 0 && sum % i == 0){\n ...
aoj_2028_cpp
Problem G: Gather on the Clock There is a self-playing game called Gather on the Clock . At the beginning of a game, a number of cards are placed on a ring. Each card is labeled by a value. In each step of a game, you pick up any one of the cards on the ring and put it on the next one in clockwise order. You will gain ...
[ { "submission_id": "aoj_2028_10853924", "code_snippet": "#include <cmath>\n#include <vector>\n#include <iostream>\n#include <algorithm>\nusing namespace std;\nint Q, n;\nint main() {\n\tcin >> Q;\n\twhile (Q--) {\n\t\tcin >> n;\n\t\tvector<int> a(n);\n\t\tfor (int i = 0; i < n; i++) cin >> a[i];\n\t\tint re...
aoj_2031_cpp
Problem B: Hyper Rock-Scissors-Paper Rock-Scissors-Paper is a game played with hands and often used for random choice of a person for some purpose. Today, we have got an extended version, namely, Hyper Rock-Scissors-Paper (or Hyper RSP for short). In a game of Hyper RSP, the players simultaneously presents their hands ...
[ { "submission_id": "aoj_2031_10858250", "code_snippet": "#include <string>\n#include <vector>\n#include <iostream>\n#include <algorithm>\nusing namespace std;\nvector<string> r = {\n\t\"Rock\",\n\t\"Gun\",\n\t\"Lightning\",\n\t\"Devil\",\n\t\"Dragon\",\n\t\"Water\",\n\t\"Air\",\n\t\"Paper\",\n\t\"Sponge\",\...
aoj_2036_cpp
Problem G: Traffic You are a resident of Kyoot (oh, well, it’s not a misspelling!) city. All streets there are neatly built on a grid; some streets run in a meridional (north-south) direction and others in a zonal (east-west) direction. The streets that run from north to south are called avenues, whereas those which ru...
[ { "submission_id": "aoj_2036_6775560", "code_snippet": "#include<bits/stdc++.h>\nusing namespace std;\ntypedef long long int ll;\ntypedef unsigned long long int ull;\n#define chmin(x,y) x = min(x,y)\n#define chmax(x,y) x = max(x,y)\n#define BIG_NUM 2000000000\n#define HUGE_NUM 4000000000000000000 //オーバーフローに...
aoj_2030_cpp
Problem A: Ruins In 1936, a dictator Hiedler who aimed at world domination had a deep obsession with the Lost Ark . A person with this ark would gain mystic power according to legend. To break the ambition of the dictator, ACM (the Alliance of Crusaders against Mazis) entrusted a secret task to an archeologist Indiana ...
[ { "submission_id": "aoj_2030_2645406", "code_snippet": "#include \"bits/stdc++.h\"\n#include<unordered_map>\n#include<unordered_set>\n#pragma warning(disable:4996)\nusing namespace std;\n\nvector<long long int> divisor(long long int n) {\n\tvector<long long int> res;\n\tfor (long long int i = 1; i * i <= n;...
aoj_2034_cpp
Problem E: Autocorrelation Function Nathan O. Davis is taking a class of signal processing as a student in engineering. Today’s topic of the class was autocorrelation. It is a mathematical tool for analysis of signals represented by functions or series of values. Autocorrelation gives correlation of a signal with itsel...
[ { "submission_id": "aoj_2034_10794058", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n \n cout.setf(ios::fixed);\n cout << setprecision(15);\n\n int n;\n long double r;\n while ( (cin >> n >> r) ) {...
aoj_2035_cpp
Problem F: It Prefokery Pio You are a member of a secret society named Japanese Abekobe Group , which is called J. A. G. for short. Those who belong to this society often exchange encrypted messages. You received lots of encrypted messages this morning, and you tried to decrypt them as usual. However, because you recei...
[ { "submission_id": "aoj_2035_10722445", "code_snippet": "#include<bits/stdc++.h>\n//#include<atcoder/all>\nusing namespace std;\n//using namespace atcoder;\n\nusing ll = long long;\nusing ld = long double;\n\n//using mint = modint998244353;\n//using mint = modint1000000007;\n\ntemplate<class T> using pq = p...
aoj_2041_cpp
Problem C: Disarmament of the Units This is a story in a country far away. In this country, two armed groups, ACM and ICPC, have fought in the civil war for many years. However, today October 21, reconciliation was approved between them; they have marked a turning point in their histories. In this country, there are a ...
[ { "submission_id": "aoj_2041_124929", "code_snippet": "#include<iostream>\n#include<complex>\n#include<map>\n#include<algorithm>\n#include<set>\n#include<queue>\nusing namespace std;\n#define REP(i,b,n) for(int i=b;i<n;i++)\n#define rep(i,n) REP(i,0,n)\n#define pb push_back\n#define mp make_pair\n#define ...
aoj_2033_cpp
Problem D: Rock Man You were the master craftsman in the stone age, and you devoted your life to carving many varieties of tools out of natural stones. Your works have ever been displayed respectfully in many museums, even in 2006 A.D. However, most people visiting the museums do not spend so much time to look at your ...
[ { "submission_id": "aoj_2033_10852644", "code_snippet": "#include <bits/stdc++.h>\n \n#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )\n#define REP(i,n) FOR(i,0,n)\n#define YYS(x,arr) for(auto& x:arr)\n#define ALL(x) (x).begin(),(x).end()\n#define SORT(x) sort( (x).begin(),(x).end() )\n#define RE...
aoj_2044_cpp
Problem F: Lying about Your Age You have moved to a new town. As starting a new life, you have made up your mind to do one thing: lying about your age. Since no person in this town knows your history, you don’t have to worry about immediate exposure. Also, in order to ease your conscience somewhat, you have decided to ...
[ { "submission_id": "aoj_2044_9685683", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\n\nint main() {\n int a,b,c;\n while(cin >> a >> b >> c && a!=-1) {\n bool f=0;\n for(int i=2; i<17; i++) {\n int x=0,z=a;\n string s=\"\";\n while(z) {\n s+=(char)(z%i+'0');\...
aoj_2042_cpp
Problem D: So Sleepy You have an appointment to meet a friend of yours today, but you are so sleepy because you didn’t sleep well last night. As you will go by trains to the station for the rendezvous, you can have a sleep on a train. You can start to sleep as soon as you get on a train and keep asleep just until you g...
[ { "submission_id": "aoj_2042_10850499", "code_snippet": "#include <cstdio>\n#include <cstring>\n#include <vector>\n\nusing namespace std;\n\nint dp[1000][24 * 60][2];\nint n, m, dest, destTime;\n\nvector<pair<int, int>> lines[100], stationInfo[1000][24 * 60]; // time, station / line index\n\nint getAns(int ...
aoj_2046_cpp
Problem H: Robot's Crash Prof. Jenifer A. Gibson is carrying out experiments with many robots. Since those robots are expensive, she wants to avoid their crashes during her experiments at her all effort. So she asked you, her assistant, as follows. “Suppose that we have n (2 ≤ n ≤ 100000) robots of the circular shape w...
[ { "submission_id": "aoj_2046_8436730", "code_snippet": "#include<bits/stdc++.h>\nusing namespace std;\ntypedef long long int ll;\ntypedef unsigned long long int ull;\n#define chmin(x,y) x = min(x,y)\n#define chmax(x,y) x = max(x,y)\n#define BIG_NUM 2000000000\n#define HUGE_NUM 4000000000000000000 //オーバーフローに...
aoj_2040_cpp
Problem B: Sort the Panels There was an explorer Henry Nelson traveling all over the world. One day he reached an ancient building. He decided to enter this building for his interest, but its entrance seemed to be locked by a strange security system. There were some black and white panels placed on a line at equal inte...
[ { "submission_id": "aoj_2040_10853102", "code_snippet": "#include <cstring>\n#include <iostream>\n#include <string>\n\nusing namespace std;\n\nint getStat(string arg) {\n\tint ret = 0;\n\tfor(char ch: arg)\n\t\tif(ch == 'B') ret = ret * 2 + 1;\n\t\telse ret *= 2;\n\treturn ret;\n}\n\nint dp[1 << 16][16];\ni...
aoj_2039_cpp
Problem A: Space Coconut Crab II A space hunter, Ken Marineblue traveled the universe, looking for the space coconut crab. The space coconut crab was a crustacean known to be the largest in the universe. It was said that the space coconut crab had a body of more than 400 meters long and a leg span of no shorter than 10...
[ { "submission_id": "aoj_2039_10850472", "code_snippet": "#include <stdio.h>\n#define MAX 30010\n\nint dy[MAX], prime[MAX];\nint n, pcnt;\nbool p[MAX];\n\nvoid getprime(void){\n\tint i, j;\n\tfor (i=2;i<=15000;i++){\n\t\tif (p[i]) continue;\n\t\tprime[++pcnt]=i;\n\t\tfor (j=i*i;j<=15000;j+=i){\n\t\t\tp[j]=1;...
aoj_2048_cpp
Problem A: Everlasting...? Everlasting Sa-Ga, a new, hot and very popular role-playing game, is out on October 19, 2008. Fans have been looking forward to a new title of Everlasting Sa-Ga. Little Jimmy is in trouble. He is a seven-year-old boy, and he obtained the Everlasting Sa-Ga and is attempting to reach the end of...
[ { "submission_id": "aoj_2048_4109877", "code_snippet": "#include <iostream>\n#include <vector>\n#include <algorithm>\n#include <map>\nusing namespace std;\ntypedef long long int ll;\n\nint key(int x){\n\tint s=0,m=0;\n\tfor(int i=2;i<=x;i++){\n\t\tif(x%i==0){\n\t\t\ts+=i;\n\t\t\tm=i;\n\t\t\twhile(x%i==0){\n...
aoj_2045_cpp
Problem G: Turn Polygons HCII, the health committee for interstellar intelligence, aims to take care of the health of every interstellar intelligence. Staff of HCII uses a special equipment for health checks of patients. This equipment looks like a polygon-shaped room with plenty of instruments. The staff puts a patien...
[ { "submission_id": "aoj_2045_5499629", "code_snippet": "#include<bits/stdc++.h>\ntypedef long long int ll;\ntypedef unsigned long long int ull;\n#define BIG_NUM 2000000000\n#define HUGE_NUM 4000000000000000000 //オーバーフローに注意\n#define MOD 1000000007\n//#define EPS 0.000000001\nusing namespace std;\n\n\n#define...
aoj_2050_cpp
Problem C: Dig or Climb Benjamin Forest VIII is a king of a country. One of his best friends Nod lives in a village far from his castle. Nod gets seriously sick and is on the verge of death. Benjamin orders his subordinate Red to bring good medicine for him as soon as possible. However, there is no road from the castle...
[ { "submission_id": "aoj_2050_3057190", "code_snippet": "#include <iostream>\n#include <iomanip>\n#include <complex>\n#include <vector>\n#include <algorithm>\n#include <cmath>\n#include <array>\n#include <map>\n#include <queue>\nusing namespace std;\nconst double EPS = 1e-6;\nconst double INF = 1e12;\nconst ...
aoj_2049_cpp
Problem B: Headstrong Student You are a teacher at a cram school for elementary school pupils. One day, you showed your students how to calculate division of fraction in a class of mathematics. Your lesson was kind and fluent, and it seemed everything was going so well - except for one thing. After some experiences, a ...
[ { "submission_id": "aoj_2049_10748216", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\nint m[1000005];\n\nint main() {\n ios_base::sync_with_stdio(false); cin.tie(NULL);\n while (true) {\n int x, y; cin >> x >> y;\n if (!x) break;\n for (int i = 0;i < y;i++) m[i]...
aoj_2054_cpp
Problem G: Entangled Tree The electronics division in Ishimatsu Company consists of various development departments for electronic devices including disks and storages, network devices, mobile phones, and many others. Each department covers a wide range of products. For example, the department of disks and storages dev...
[ { "submission_id": "aoj_2054_1679749", "code_snippet": "#include <bits/stdc++.h>\n\n#define x first\n#define y second\n#define pb push_back\n#define pii pair<int,int>\n#define ll long long\n#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); i++)\n#define REP(i, a) FOR(i, 0, a)\n#define TRACE(x) cout <...
aoj_2055_cpp
Problem H: Ramen Shop Ron is a master of a ramen shop. Recently, he has noticed some customers wait for a long time. This has been caused by lack of seats during lunch time. Customers loses their satisfaction if they waits for a long time, and even some of them will give up waiting and go away. For this reason, he has ...
[ { "submission_id": "aoj_2055_9149012", "code_snippet": "#include<bits/stdc++.h>\nusing namespace std;\ntypedef long long int ll;\ntypedef unsigned long long int ull;\n#define chmin(x,y) x = min(x,y)\n#define chmax(x,y) x = max(x,y)\n#define BIG_NUM 2000000000\n#define HUGE_NUM 4000000000000000000 //オーバーフローに...
aoj_2051_cpp
Problem D: Rotation Estimation Mr. Nod is an astrologist and has defined a new constellation. He took two photos of the constellation to foretell a future of his friend. The constellation consists of n stars. The shape of the constellation in these photos are the same, but the angle of them are different because these ...
[ { "submission_id": "aoj_2051_5500120", "code_snippet": "#include<bits/stdc++.h>\ntypedef long long int ll;\ntypedef unsigned long long int ull;\n#define BIG_NUM 2000000000\n#define HUGE_NUM 4000000000000000000 //オーバーフローに注意\n#define MOD 1000000007\n//#define EPS 0.000000001\nusing namespace std;\n\n\n#define...
aoj_2053_cpp
Problem F: Controlled Tournament National Association of Tennis is planning to hold a tennis competition among professional players. The competition is going to be a knockout tournament, and you are assigned the task to make the arrangement of players in the tournament. You are given the detailed report about all parti...
[ { "submission_id": "aoj_2053_10848151", "code_snippet": "#include<bits/stdc++.h>\nusing namespace std;\nconst int MAXN = 1 << 16;\nint n, m;\nint bit1[MAXN]; // 二进制数中有多少个 1\nint dp[20][10][MAXN];\nvector<int> G[20];\nint dfs(int u, int h, int bits) {\n if(bit1[bits] == 1) return 1;\n if((1 << h) < bit...
aoj_2052_cpp
Problem E: Optimal Rest Music Macro Language (MML) is a language for textual representation of musical scores. Although there are various dialects of MML, all of them provide a set of commands to describe scores, such as commands for notes, rests, octaves, volumes, and so forth. In this problem, we focus on rests, i.e....
[ { "submission_id": "aoj_2052_10233879", "code_snippet": "// AOJ #2052 Optimal Rest\n// 2025.2.20\n\n#include <bits/stdc++.h>\nusing namespace std;\nconst int INF = 1e9;\n\nstruct Coin {\n string s;\n int cost;\n int value;\n};\n \nint main() {\n ios::sync_with_stdio(0);\n cin.tie(0);\n \n ...
aoj_2059_cpp
Problem B: Restaurant Steve runs a small restaurant in a city. Also, as he is the only cook in his restaurant, he cooks everything ordered by customers. Basically he attends to orders by first-come-first-served principle. He takes some prescribed time to prepare each dish. As a customer can order more than one dish at ...
[ { "submission_id": "aoj_2059_1367835", "code_snippet": "#include<cstdio>\n#include<cstdlib>\n#include<cstring>\n#include<cmath>\n#include<iostream>\n#include<string>\n#include<vector>\n#include<map>\n#include<set>\n#include<list>\n#include<queue>\n#include<deque>\n#include<algorithm>\n#include<numeric>\n#in...
aoj_2058_cpp
Problem A: Moduic Squares Have you ever heard of Moduic Squares? They are like 3 × 3 Magic Squares, but each of them has one extra cell called a moduic cell. Hence a Moduic Square has the following form. Figure 1: A Moduic Square Each of cells labeled from A to J contains one number from 1 to 10, where no two cells con...
[ { "submission_id": "aoj_2058_6825904", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\n\nint a[3][3], m, ans;\nbool chk[11];\n\nvoid f(int p) {\n\tif (p == 10) {\n\t\tset<int> num, mod;\n\t\tnum.insert(m);\n\t\tfor (int i = 0; i < 3; i++) {\n\t\t\tfor (int j = 0; j < 3; j++) num.insert(a[i]...
aoj_2062_cpp
Problem E: Hide-and-seek Hide-and-seek is a children’s game. Players hide here and there, and one player called it tries to find all the other players. Now you played it and found all the players, so it’s turn to hide from it . Since you have got tired of running around for finding players, you don’t want to play it ag...
[ { "submission_id": "aoj_2062_3114687", "code_snippet": "#include <iostream>\n#include <iomanip>\n#include <complex>\n#include <vector>\n#include <algorithm>\n#include <cmath>\n#include <array>\n#include <map>\n#include <utility>\n#include <queue>\nusing namespace std;\nconst double EPS = 1e-8;\nconst double...
aoj_2063_cpp
Problem F: TV Watching You are addicted to watching TV, and you watch so many TV programs every day. You have been in trouble recently: the airtimes of your favorite TV programs overlap. Fortunately, you have both a TV and a video recorder at your home. You can therefore watch a program on air while another program (on...
[ { "submission_id": "aoj_2063_10312968", "code_snippet": "// AOJ #2063 TV Watching\n// 2025.3.20\n\n#include <bits/stdc++.h>\nusing namespace std;\n\nstruct Prog { int s, e, r1, r2; };\n\nint toMin(const string &t) {\n int hh = stoi(t.substr(0, t.find(':')));\n int mm = stoi(t.substr(t.find(':')+1));\n...
aoj_2066_cpp
Problem I: Roads in a City Roads in a city play important roles in development of the city. Once a road is built, people start their living around the road. A broader road has a bigger capacity, that is, people can live on a wider area around the road. Interstellar Conglomerate of Plantation and Colonization (ICPC) is ...
[ { "submission_id": "aoj_2066_5469291", "code_snippet": "#include <bits/stdc++.h>\n#include <stdlib.h>\n#include <cassert>\nusing namespace std;\ntypedef long long ll;\ntypedef vector<ll> vec;\n\n#define _GLIBCXX_DEBUG\n#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)\n#define rep(i,n) REP(i,0,n)\n#define p...
aoj_2057_cpp
The Closest Circle You are given N non-overlapping circles in xy-plane. The radius of each circle varies, but the radius of the largest circle is not double longer than that of the smallest. Figure 1: The Sample Input The distance between two circles C 1 and C 2 is given by the usual formula where ( x i , y i ) is the ...
[ { "submission_id": "aoj_2057_10946135", "code_snippet": "#include <cstdio>\n#include <cstring>\n#include <algorithm>\n#include <cmath>\n#define ele int\nusing namespace std;\n#define maxn 100010\n#define INF 1e18\n#define eps 1e-7\nstruct circle{\n\tdouble x,y,r;\n};\nele n;\ndouble R;\ncircle a[maxn];\ninl...
aoj_2065_cpp
Problem H: Slippy Floors The princess of the Fancy Kingdom has been loved by many people for her lovely face. However the witch of the Snow World has been jealous of the princess being loved. For her jealousy, the witch has shut the princess into the Ice Tower built by the witch’s extreme magical power. As the Ice Towe...
[ { "submission_id": "aoj_2065_861603", "code_snippet": "/*\n00:42 - 01:17\n */\n\n#include<iostream>\n#include<algorithm>\n#include<climits>\n#include<cstdio>\n\n#define REP(i,s,n) for(int i=s;i<n;i++)\n#define rep(i,n) REP(i,0,n)\n#define IINF (INT_MAX)\n#define MAX 31\nusing namespace std;\n\nint H,W;\nboo...
aoj_2061_cpp
Problem D: International Party Isaac H. Ives is attending an international student party (maybe for girl-hunting). Students there enjoy talking in groups with excellent foods and drinks. However, since students come to the party from all over the world, groups may not have a language spoken by all students of the group...
[ { "submission_id": "aoj_2061_10532388", "code_snippet": "#include \"bits/stdc++.h\"\n#include <ext/pb_ds/assoc_container.hpp>\n#include <ext/pb_ds/tree_policy.hpp>\n#include <ext/pb_ds/tag_and_trait.hpp>\nusing namespace __gnu_pbds;\nusing namespace std;\nusing ll = long long;\nusing ld = long double;\nusin...
aoj_2060_cpp
Problem C: Tetrahedra Peter P. Pepper is facing a difficulty. After fierce battles with the Principality of Croode, the Aaronbarc Kingdom, for which he serves, had the last laugh in the end. Peter had done great service in the war, and the king decided to give him a big reward. But alas, the mean king gave him a hard q...
[ { "submission_id": "aoj_2060_9723100", "code_snippet": "#include \"bits/stdc++.h\"\n\nusing namespace std;\n\nint s[3];\n\nbool f1(int a, int b, int c) {\n s[0] = a, s[1] = b, s[2] = c;\n sort(s, s + 3);\n return s[0] + s[1] > s[2];\n}\n\ndouble f2(double l1, double l2, double l3, double l4, double...
aoj_2064_cpp
Problem G: Make Friendships Isaac H. Ives attended an international student party and made a lot of girl friends (as many other persons expected). To strike up a good friendship with them, he decided to have dates with them. However, it is hard for him to schedule dates because he made so many friends. Thus he decided ...
[ { "submission_id": "aoj_2064_11055694", "code_snippet": "#include <bits/stdc++.h>\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\n#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)\n#define rrep(i,start,end) for (ll i = start;i >= (ll)(end);i--)\n#defi...
aoj_2067_cpp
Reading Brackets in English Shun and his professor are studying Lisp and S-expressions. Shun is in Tokyo in order to make a presen- tation of their research. His professor cannot go with him because of another work today. He was making final checks for his slides an hour ago. Then, unfortunately, he found some serious ...
[ { "submission_id": "aoj_2067_10313005", "code_snippet": "// AOJ #2067 Reading Brackets in English\n// 2025.3.20\n\n#include <bits/stdc++.h>\nusing namespace std;\n\nstruct Ans {\n bool valid, amb;\n string s;\n};\n\nAns mergeAns(const Ans &a, const Ans &b) {\n if(!a.valid) return b;\n if(!b.vali...
aoj_2073_cpp
The Phantom Mr. Hoge is in trouble. He just bought a new mansion, but it’s haunted by a phantom. He asked a famous conjurer Dr. Huga to get rid of the phantom. Dr. Huga went to see the mansion, and found that the phantom is scared by its own mirror images. Dr. Huga set two flat mirrors in order to get rid of the phanto...
[ { "submission_id": "aoj_2073_3224441", "code_snippet": "#include <iostream>\n#include <iomanip>\n#include <complex>\n#include <vector>\n#include <algorithm>\n#include <cmath>\n#include <array>\n#include <utility>\nusing namespace std;\nconst double EPS = 1e-8;\nconst double INF = 1e12;\n#define EQ(n,m) (abs...
aoj_2075_cpp
Dock to the Future You had long wanted a spaceship, and finally you bought a used one yesterday! You have heard that the most difficult thing on spaceship driving is to stop your ship at the right position in the dock. Of course you are no exception. After a dozen of failures, you gave up doing all the docking process ...
[ { "submission_id": "aoj_2075_9659676", "code_snippet": "#include <iostream>\n#include <vector>\n#include <iomanip>\nusing namespace std;\nvoid solve(){\n int n, q;\n cin >> n;\n vector<int> a(n);\n for (int i = 0; i < n; i++) cin >> a[i];\n cin >> q;\n while (q--){\n int x, v;\n ...
aoj_2071_cpp
Web 0.5 In a forest, there lived a spider named Tim. Tim was so smart that he created a huge, well-structured web. Surprisingly, his web forms a set of equilateral and concentric N -sided polygons whose edge lengths form an arithmetic sequence. Figure 1: An example web of Tim Corresponding vertices of the N-sided polyg...
[ { "submission_id": "aoj_2071_4823005", "code_snippet": "#include<bits/stdc++.h>\ntypedef long long int ll;\ntypedef unsigned long long int ull;\n#define BIG_NUM 2000000000\n#define HUGE_NUM 1000000000000000000\n#define MOD 1000000007\n#define EPS 0.000000001\nusing namespace std;\n\n\n\n#define SIZE 605\n\n...