id
stringlengths
11
112
content
stringlengths
42
13k
test
listlengths
0
565
labels
dict
canonical_solution
dict
HackerEarth/uncles-will-1
Ramu’s uncle has left him a stable in his Will. But the stable is not in a good condition. The roofs leak and need to be repaired. There are a number of stalls in the stable. A stall may or may not contain a horse. Ramu has to buy new cement sheets to cover these stalls. He has to cover atleast all those stalls that h...
[ { "input": { "stdin": "1\n2 10 3\n2\n4\n10\n\nSAMPLE" }, "output": { "stdout": "4" } } ]
{ "tags": [], "title": "uncles-will-1" }
{ "cpp": null, "java": null, "python": "# /he/uncle's-will\n\nno_of_tc = input()\nfor tc in range(no_of_tc) :\n\tline = raw_input()\n\tmax_sheets = int(line.split(' ')[0])\n\ttotal_stalls = int(line.split(' ')[1])\n\tfilled_stalls = int(line.split(' ')[2])\n\tstall_map = [False] * total_stalls\n\tfor i in range(f...
p02586 AtCoder Beginner Contest 175 - Picking Goods
There are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \leq i \leq R) and the j-th column (1 \leq j \leq C). The i-th item is at (r_i, c_i) and has the value v_i. Takahashi will begin at (1, 1), the start, and get to (R, C), the goal. When he is at (i, ...
[ { "input": { "stdin": "2 5 5\n1 1 3\n2 4 20\n1 2 1\n1 3 4\n1 4 2" }, "output": { "stdout": "29" } }, { "input": { "stdin": "2 2 3\n1 1 3\n2 1 4\n1 2 5" }, "output": { "stdout": "8" } }, { "input": { "stdin": "4 5 10\n2 5 12\n1 5 12\n2 3 15\n1...
{ "tags": [], "title": "p02586 AtCoder Beginner Contest 175 - Picking Goods" }
{ "cpp": "#include<iostream>\nusing namespace std;\nlong long maps[3005][3005]={0};\nlong long dp[3005][3005][5]={0};\nint main(){\n int h,w;\n int k;\n \n \n cin>>h>>w;\n cin>>k;\n for(int i=0;i<k;i++){\n int r,c,v;\n cin>>r>>c>>v;\n maps[r][c]=v;\n }\n \n\n dp[1][1][1]=maps[1][1];\n for(int i=1;...
p02717 AtCoder Beginner Contest 161 - ABC Swap
We have three boxes A, B, and C, each of which contains an integer. Currently, the boxes A, B, and C contain the integers X, Y, and Z, respectively. We will now do the operations below in order. Find the content of each box afterward. * Swap the contents of the boxes A and B * Swap the contents of the boxes A and C C...
[ { "input": { "stdin": "100 100 100" }, "output": { "stdout": "100 100 100" } }, { "input": { "stdin": "41 59 31" }, "output": { "stdout": "31 41 59" } }, { "input": { "stdin": "1 2 3" }, "output": { "stdout": "3 1 2" } }, ...
{ "tags": [], "title": "p02717 AtCoder Beginner Contest 161 - ABC Swap" }
{ "cpp": "#include <cstdio>\n\n\n\nint main(){\n int A,B,C;\n scanf(\"%d%d%d\",&A,&B,&C);\n\n printf(\"%d %d %d\\n\",C,A,B);\n\n return 0;\n}", "java": " import java.util.*;\n public class Main {\n \tpublic static void main(String[] args){\n \t\tScanner sc = new Scanner(System.in...
p02846 Sumitomo Mitsui Trust Bank Programming Contest 2019 - Interval Running
Takahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east. They start simultaneously at the same point and moves as follows towards the east: * Takahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for the subse...
[ { "input": { "stdin": "1 2\n10 10\n12 4" }, "output": { "stdout": "1" } }, { "input": { "stdin": "100 1\n101 101\n102 1" }, "output": { "stdout": "infinity" } }, { "input": { "stdin": "12000 15700\n3390000000 3810000000\n5550000000 2130000000...
{ "tags": [], "title": "p02846 Sumitomo Mitsui Trust Bank Programming Contest 2019 - Interval Running" }
{ "cpp": "#include <iostream>\n\nusing namespace std;\n\ntypedef long long ll;\n\n\nint main() {\n ll t1,t2;\n ll a1,a2,b1,b2;\n cin >> t1 >> t2;\n cin >> a1 >> a2;\n cin >> b1 >> b2;\n\n if(t1*a1 < t1*b1) {\n swap(a1,b1);\n swap(a2,b2);\n }\n \n\n ll tmp1 = t1*a1-t1*b1;\n\t\t\t \n ll tmp2 = t1*a1+t2...
p02983 AtCoder Beginner Contest 133 - Remainder Minimization 2019
You are given two non-negative integers L and R. We will choose two integers i and j such that L \leq i < j \leq R. Find the minimum possible value of (i \times j) \mbox{ mod } 2019. Constraints * All values in input are integers. * 0 \leq L < R \leq 2 \times 10^9 Input Input is given from Standard Input in the fol...
[ { "input": { "stdin": "4 5" }, "output": { "stdout": "20" } }, { "input": { "stdin": "2020 2040" }, "output": { "stdout": "2" } }, { "input": { "stdin": "0 64" }, "output": { "stdout": "0\n" } }, { "input": { "...
{ "tags": [], "title": "p02983 AtCoder Beginner Contest 133 - Remainder Minimization 2019" }
{ "cpp": "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int64_t l, r;\n cin >> l >> r;\n r = min(r, l+2019);\n int ans = 2018;\n for(int64_t i=l; i<r; i++){\n for(int64_t j=i+1; j<=r; j++){\n int x = (int64_t)i*j%2019;\n ans = min(ans, x);\n }\n }\n cout << ans << endl;\n}", ...
p03125 AtCoder Beginner Contest 118 - B +/- A
You are given positive integers A and B. If A is a divisor of B, print A + B; otherwise, print B - A. Constraints * All values in input are integers. * 1 \leq A \leq B \leq 20 Input Input is given from Standard Input in the following format: A B Output If A is a divisor of B, print A + B; otherwise, print B -...
[ { "input": { "stdin": "4 12" }, "output": { "stdout": "16" } }, { "input": { "stdin": "8 20" }, "output": { "stdout": "12" } }, { "input": { "stdin": "1 1" }, "output": { "stdout": "2" } }, { "input": { "stdin"...
{ "tags": [], "title": "p03125 AtCoder Beginner Contest 118 - B +/- A" }
{ "cpp": "#include<iostream>\nusing namespace std;\n\nint main(){\n int a,b; cin >> a >> b;\n cout << (b%a ? b-a : a+b);\n}", "java": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static void main(String[] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tint a = sc.nextInt(), b = sc.nextIn...
p03267 AtCoder Beginner Contest 108 - All Your Paths are Different Lengths
You are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists. * The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N. * The number o...
[ { "input": { "stdin": "4" }, "output": { "stdout": "8 10\n1 2 0\n2 3 0\n3 4 0\n1 5 0\n2 6 0\n3 7 0\n4 8 0\n5 6 1\n6 7 1\n7 8 1" } }, { "input": { "stdin": "5" }, "output": { "stdout": "5 7\n1 2 0\n2 3 1\n3 4 0\n4 5 0\n2 4 0\n1 3 3\n3 5 1" } }, { "i...
{ "tags": [], "title": "p03267 AtCoder Beginner Contest 108 - All Your Paths are Different Lengths" }
{ "cpp": "#include<iostream>\n#include<climits>\n#include<algorithm>\n#include<cmath>\n#include<vector>\n#include<string>\nusing namespace std;\ntypedef long long ll;\n\nll log(ll x, ll n){\n\tif(x==1){\n\t\treturn n;\n\t}else{\n\t\treturn log(x/2, n+1);\n\t}\n}\n\nll beki(ll x , ll n){\n\t\n\tll ans = 1;\n\tfor(int ...
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choo...
[ { "input": { "stdin": "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI" }, "output": { "stdout": "2" } }, { "input": { "stdin": "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO" }, "output": { "stdout": "7" } }, { "input": { "stdin": "4\nZZ\nZZZ\nZ\nZZZZZZ...
{ "tags": [], "title": "p03425 AtCoder Beginner Contest 089 - March" }
{ "cpp": "#include <bits/stdc++.h>\nusing namespace std;\n\nint main(){\n\tlong int n,ma=0,aa=0,ra=0,ca=0,ha=0;\n \tcin >> n;\n \tfor (int i=0;i<n;i++){\n \tstring t;\n \tcin >> t;\n \tif (t[0]=='M' ) ma++;\n if (t[0]=='A' ) aa++;\n \tif (t[0]=='R' ) ra++;\n \tif (t[0]=='C' ) ca++;\n ...
p03582 CODE FESTIVAL 2017 qual B - Largest Smallest Cyclic Shift
For a string S, let f(S) be the lexicographically smallest cyclic shift of S. For example, if S = `babca`, f(S) = `ababc` because this is the smallest among all cyclic shifts (`babca`, `abcab`, `bcaba`, `cabab`, `ababc`). You are given three integers X, Y, and Z. You want to construct a string T that consists of exact...
[ { "input": { "stdin": "2 2 0" }, "output": { "stdout": "abab" } }, { "input": { "stdin": "1 1 1" }, "output": { "stdout": "acb" } }, { "input": { "stdin": "8 0 2" }, "output": { "stdout": "aaaacaaaac\n" } }, { "input...
{ "tags": [], "title": "p03582 CODE FESTIVAL 2017 qual B - Largest Smallest Cyclic Shift" }
{ "cpp": "#include <bits/stdc++.h>\nusing namespace std;\n\nlong long int X, Y, Z, S, K;\n\nstatic inline void exap(string &src, string s, long long int t){\n for(int i = 0; i < t; ++i)src += s;\n}\n\nvoid twoletter(long long X, long long Y, string xc, string yc){\n while(X && Y){\n if(X > Y){\n ...
p03739 AtCoder Beginner Contest 059 - Sequence
You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-...
[ { "input": { "stdin": "5\n3 -6 4 -5 7" }, "output": { "stdout": "0" } }, { "input": { "stdin": "4\n1 -3 1 0" }, "output": { "stdout": "4" } }, { "input": { "stdin": "6\n-1 4 3 2 -5 4" }, "output": { "stdout": "8" } }, { ...
{ "tags": [], "title": "p03739 AtCoder Beginner Contest 059 - Sequence" }
{ "cpp": "#include <bits/stdc++.h>\nusing namespace std;\n#define int long long\n\nint solvePlus(vector<int> v) {\n int cnt = 0, sum = 0;\n\n for (int i = 0; i < v.size(); i++) {\n sum += v[i];\n if (i % 2 == 1) {\n cnt = (sum < 0) ? cnt : (cnt + abs(sum) + 1);\n sum = (sum < 0) ? sum : -1;\n } e...
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing!
Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki. Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneou...
[ { "input": { "stdin": "6\n40" }, "output": { "stdout": "7.5000000" } }, { "input": { "stdin": "101\n80" }, "output": { "stdout": "63.7500000" } }, { "input": { "stdin": "3\n100" }, "output": { "stdout": "2.0000000" } }, ...
{ "tags": [], "title": "p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing!" }
{ "cpp": "// #pragma GCC target(\"avx2\") // CPU 処理並列化\n// #pragma GCC optimize(\"O3\") // CPU 処理並列化\n// #pragma GCC optimize(\"unroll-loops\") // 条件処理の呼び出しを減らす\n#include<stdio.h>\n#include<math.h>\n#include<algorithm>\n#include<queue>\n#include<deque>\n#include<stack>\n#include<string>\n#include<string.h>\n#inclu...
AIZU/p00007
# Debt Hell Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week. Write a program which computes the amount of the debt in n weeks. Input An integer n (0 ≤ ...
[ { "input": { "stdin": "5" }, "output": { "stdout": "130000" } }, { "input": { "stdin": "4" }, "output": { "stdout": "123000\n" } }, { "input": { "stdin": "143" }, "output": { "stdout": "115848000\n" } }, { "input": {...
{ "tags": [], "title": "Debt Hell" }
{ "cpp": "#include <iostream>\n#include <cmath>\n\nusing namespace std;\n\nint main() {\n int n, m = 100;\n cin >> n;\n while (n--) {\n m = ceil(m * 1.05);\n }\n cout << m * 1000 << endl;\n\n return 0;\n}", "java": "import java.util.*;\n\npublic class Main{\n\tprivate static final Scanner s...
AIZU/p00139
# Snakes In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Clas...
[ { "input": { "stdin": "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" }, "output": { "stdout": "A\nB\nNA" } }, { "input": { "stdin": "3\n&<==>==#><:~=?=<\n~~=Q=R=R<Q=P==QQ=]>Q=Q\n=>?#?'=?>}=" }, "output": { "stdout": "NA\nNA\nNA\n" } }, { ...
{ "tags": [], "title": "Snakes" }
{ "cpp": "#include <bits/stdc++.h>\nusing namespace std;\n\nint main() {\n int T;\n cin >> T;\n while(T--) {\n string s;\n cin >> s;\n if(s[0]!='>'||s.size()<=3) cout << \"NA\" << endl;\n else if(s[1]=='\\'') {\n if(s[s.size()-1]!='~'||s.size()%2) {\n cout << \"NA\" << endl;\n goto n...
AIZU/p00272
# Ticket Sales Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well!...
[ { "input": { "stdin": "3 10\n1 4\n4 1\n2 5" }, "output": { "stdout": "30000\n24000\n2000\n20000" } }, { "input": { "stdin": "3 10\n1 0\n4 2\n2 5" }, "output": { "stdout": "30000\n0\n4000\n20000\n" } }, { "input": { "stdin": "3 10\n1 4\n4 1\n1...
{ "tags": [], "title": "Ticket Sales" }
{ "cpp": "#include<iostream>\nusing namespace std ;\n\nint main(){\n\t\n\tint t , n ;\n\tint k[5] = { 0,6000,4000,3000,2000 } ;\n\t\n\tfor( int i=0 ; i<4 ; i++ ){\n\t\tcin >> t >> n ;\n\t\tcout << k[t] * n << endl ;\n\t}\n\t\nreturn 0; \n}", "java": "import java.util.Scanner;\n\npublic class Main {\n\tpublic static...
AIZU/p00460
# Bingo problem In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions. * The Bingo card is divided into squares of N rows and N columns, and...
[ { "input": { "stdin": "3 9 45\n3 100 50\n5 50 685\n0 0 0" }, "output": { "stdout": "1\n7\n74501" } }, { "input": { "stdin": "2 19 43\n4 001 69\n1 90 548\n0 -1 -1" }, "output": { "stdout": "142\n0\n0\n" } }, { "input": { "stdin": "3 3 45\n3 10...
{ "tags": [], "title": "Bingo" }
{ "cpp": "#include <bits/stdc++.h>\nusing namespace std;\n\nusing pii = pair<int, int>;\nusing vi = vector<int>;\nusing ll = long long;\n\nconstexpr int mod = 100000;\n\nint main() {\n int N, M, S;\n while(cin >> N >> M >> S, N) {\n vector<vector<int>> dp(N * N + 1, vector<int>(S + 1));\n dp[0][0]...
AIZU/p00650
# The House of Huge Family Mr. Dango's family has an extremely huge number of members. Once it had about 100 members, and now it has as many as population of a city. It is jokingly guessed that the member might fill this planet in the near future. Mr. Dango's family, the huge family, is getting their new house. Scale...
[ { "input": { "stdin": "3 2\n0 1 2\n1 2 1\n2 1\n0 1 100\n2 1\n0 1 0\n2 1\n0 1 -1\n0 0" }, "output": { "stdout": "1\n100\n0\n-1" } }, { "input": { "stdin": "3 2\n0 2 2\n1 2 1\n2 1\n0 1 100\n2 1\n0 0 0\n2 1\n0 1 -1\n0 0" }, "output": { "stdout": "1\n100\n0\n-1\n"...
{ "tags": [], "title": "The House of Huge Family" }
{ "cpp": "#include <iostream>\n#include <cstdio>\n#include <cstdlib>\n#include <cmath>\n#include <climits>\n#include <cstring>\n#include <cctype>\n#include <algorithm>\n#include <string>\n#include <complex>\n#include <list>\n#include <vector>\n#include <stack>\n#include <queue>\n#include <deque>\n#include <set>\n#inc...
AIZU/p00795
# Co-occurrence Search A huge amount of information is being heaped on WWW. Albeit it is not well-organized, users can browse WWW as an unbounded source of up-to-date information, instead of consulting established but a little out-of-date encyclopedia. However, you can further exploit WWW by learning more about keywor...
[ { "input": { "stdin": "Thefirstexampleistrivial.\n\nmfv\n\nAhugeamountofinformationisbeingheapedonWWW.Albeititisnot\nwell-organized,userscanbrowseWWWasanunboundedsourceof\nup-to-dateinformation,insteadofconsultingestablishedbutalittle\nout-of-dateencyclopedia.However,youcanfurtherexploitWWWby\nlearningmor...
{ "tags": [], "title": "Co-occurrence Search" }
{ "cpp": "#include<iostream>\n#include<map>\n#include<cstring>\n\nusing namespace std;\n\nconst int MAX = 51;\n\nstring text, key;\nmap<char,int> M;\nint numKey[MAX];\n\ntypedef long long ll;\n\nbool input(){\n text = \"\";\n\n string s = \"\";\n if(!getline(cin,s)) return false;\n if(s == \"\") return false;\n ...
AIZU/p00926
# Shopping Example Input 10 3 3 7 8 9 2 5 Output 23
[ { "input": { "stdin": "10 3\n3 7\n8 9\n2 5" }, "output": { "stdout": "23" } }, { "input": { "stdin": "9 3\n7 0\n5 7\n1 2" }, "output": { "stdout": "16\n" } }, { "input": { "stdin": "10 2\n4 8\n8 9\n4 8" }, "output": { "stdout": ...
{ "tags": [], "title": "Shopping" }
{ "cpp": "#include<bits/stdc++.h>\nusing namespace std;\n\nint main(){\n int n,m;\n cin>>n>>m;\n vector<int> pos(n+1,1);\n for(int i=0;i<m;i++){\n int c,d;\n cin>>c>>d;\n for(int j=c;j<d;j++) pos[j]=3;\n }\n cout<<accumulate(pos.begin(),pos.end(),0)<<endl;\n \n return 0;\n...
AIZU/p01059
# Gossip Problem N idols, numbered from 1 to n in order, are lined up in a row. Idle i can transmit information to idle i-1 and idle i + 1 in a unit time. However, idol 1 can transmit information only to idol 2, and idol n can transmit information only to idol n-1. At time 0, m idols with numbers a1, a2, ..., am hav...
[ { "input": { "stdin": "10 3\n2 5 7" }, "output": { "stdout": "3" } }, { "input": { "stdin": "100000 1\n1" }, "output": { "stdout": "99999" } }, { "input": { "stdin": "10 5\n2 5 6 8 10" }, "output": { "stdout": "1" } }, {...
{ "tags": [], "title": "Gossip" }
{ "cpp": "#include <bits/stdc++.h>\nusing namespace std;\ntypedef long long ll;\ntypedef pair<int,int> P;\n\nint n,m;\nint a[100001];\n\nint main(void){\n\tscanf(\"%d%d\",&n,&m);\n\tfor(int i=0;i<m;i++){\n\t\tscanf(\"%d\",&a[i]);\n\t}\n\tint ans=max(a[0]-1,n-a[m-1]);\n\tfor(int i=0;i<m-1;i++){\n\t\tans=max(ans,(a[i+1...
AIZU/p01191
# Grated Radish Grated radish (daikon-oroshi) is one of the essential spices in Japanese cuisine. As the name shows, it’s made by grating white radish. You are developing an automated robot for grating radish. You have finally finished developing mechan- ical modules that grates radish according to given instructions...
[ { "input": { "stdin": "2\n1 2\n1\n42 3.141592653589793\n5 20\n3\n0 307.09242465218927\n180 307.09242465218927\n90 728.30573874452591" }, "output": { "stdout": "2.0 3.141592653589793\n8.660254038 5.235987756" } }, { "input": { "stdin": "2\n0 2\n1\n110 3.816742061710842\n9 12...
{ "tags": [], "title": "Grated Radish" }
{ "cpp": "#include <stdio.h>\n#include <math.h>\n#include <iostream>\n#include <complex>\n#include <vector>\n#include <utility>\n#include <algorithm>\nusing namespace std;\n#define rep(i, n) for (int i = 0; i < (int)(n); i++)\n#define mp make_pair\nconst double EPS = 1e-12;\nconst double pi = atan2(0.0, -1.0);\ntyped...
AIZU/p01329
# Stolen Jewel The jewel, a national treasure of the Kingdom of Pal, was stolen by bandits. As an adventurer, you heard the rumor and headed for the thief's hideout and managed to get the jewels back. However, when I went to return the jewel to the castle of the Kingdom of Pal, the guard of the castle said, "My king ...
[ { "input": { "stdin": "6 7\n.......\n...#...\n...#.S.\n...###.\n.G.....\n.......\n2\nLL\nDD" }, "output": { "stdout": "-1" } }, { "input": { "stdin": "7 6\n......\n.####.\n.####.\n...S#.\n...##.\n...##.\n.....G\n3\nLD\nDD\nLLL\n7 8\nS#......\n.#.####.\n.#.#G.#.\n.#.##.#.\n....
{ "tags": [], "title": "Stolen Jewel" }
{ "cpp": "#include <string>\n#include <vector>\n#include <queue>\n#include <cassert>\n#include <numeric>\n#include <iostream>\n#include <algorithm>\nusing namespace std;\n\nclass AhoCorasick{\n static const int ASIZE = 256;\n \n struct node_t {\n int ID;\n node_t *failure;\n node_t *output;\n node_...
AIZU/p01496
# Bicube Mary Thomas has a number of sheets of squared paper. Some of squares are painted either in black or some colorful color (such as red and blue) on the front side. Cutting off the unpainted part, she will have eight opened-up unit cubes. A unit cube here refers to a cube of which each face consists of one squar...
[ { "input": { "stdin": "3 40\n.a....a....a....a....f....f....f....f...\nbc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.#eb#.\n.#....#....#....#....#....#....#....#..." }, "output": { "stdout": "No" } }, { "input": { "stdin": "3 40\n.a....a....a....a....f....f....f....f...\nbc#.#cd#.#de#....
{ "tags": [], "title": "Bicube" }
{ "cpp": "#include <bits/stdc++.h>\nusing namespace std;\n\n// 0: top, 1: front, 2:right, 3:back, 4:left, 5:bottom\nconst vector<vector<string>> dice_map = {\n {\"0...\",\n \"1234\",\n \"5...\"},\n {\"0...\",\n \"1234\",\n \".5..\"},\n {\"0...\",\n \"1234\",\n \"..5.\"},\n {\"0...\...
AIZU/p01664
# Sigma I-σ A permutation of magnitude N is a sequence of elements in a sequence (1, 2, 3,…, N). For example, (5, 2, 1, 4, 3) is a permutation of size 5, while (1, 5, 1, 2, 3) is not. This problem is a reactive task. You play a response program and a "permutation guessing game". First of all, the response program in...
[ { "input": { "stdin": "" }, "output": { "stdout": "" } } ]
{ "tags": [], "title": "Sigma" }
{ "cpp": "#include<stdio.h>\n#include<algorithm>\nusing namespace std;\nint p[500];\nint q[250][500];\nint r[250][500];\nint ret[500];\nint s[500];\nint t[250][500];\nint u[500];\nint v[250][500];\nint w[250][500];\nint ABS(int a){return max(a,-a);}\nint LIM=240;\nint main(){\n\tint a;\n\tscanf(\"%d\",&a);\n\tfor(int...
AIZU/p01809
# Let's Solve Geometric Problems Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite de...
[ { "input": { "stdin": "1 2" }, "output": { "stdout": "2" } }, { "input": { "stdin": "33 596" }, "output": { "stdout": "298\n" } }, { "input": { "stdin": "3 11" }, "output": { "stdout": "11\n" } }, { "input": { ...
{ "tags": [], "title": "Let's Solve Geometric Problems" }
{ "cpp": "#include<iostream>\nusing namespace std;\nint p,q,ans=1,j;\n\nint so(int n){\n for(int i=2;i*i<=n;i++)if(n%i==0)return 1;\n return 0;\n}\n\nint main(){\n cin>>p>>q;\n if(so(q)){\n for(int i=2;q>=i;i++){\n for(j=0;q%i==0;j++){\n\tq/=i;\n\tif(p%i==0)p/=i,j--;\n }\n if(j==0)continue;\n ...
AIZU/p01944
# Almost Infinite Glico G: Almost Infinite Glico problem There is a field where N squares are arranged in a ring. The i-th (1 \ leq i \ leq N-1) cell is ahead of the i + 1th cell. However, if i = N, the next cell is the first cell. The first cell you are in is the first cell. From there, play rock-paper-scissors K ...
[ { "input": { "stdin": "10 3 2\n3\n6\n6" }, "output": { "stdout": "1\n0\n4\n2\n0\n0\n5\n0\n0\n4" } }, { "input": { "stdin": "13 3 2\n3\n10\n9" }, "output": { "stdout": "3\n0\n0\n2\n0\n1\n3\n1\n0\n2\n2\n0\n2\n" } }, { "input": { "stdin": "4 1 2...
{ "tags": [], "title": "Almost Infinite Glico" }
{ "cpp": "#include<bits/stdc++.h>\nusing namespace std;\n#define int long long\n#define MOD 1000000007\ntypedef vector<int> vec;\nvec calc(vec a,vec b){\n int n=a.size();\n vec res(n,0);\n for(int i=0;i<n;i++){\n for(int j=0;j<n;j++){\n res[(i+j)%n]+=a[i]*b[j];\n res[(i+j)%n]%=MOD;\n }\n }\n retu...
AIZU/p02093
# Invariant Tree F: Invariant Tree Problem Statement You have a permutation p_1, p_2, ... , p_N of integers from 1 to N. You also have vertices numbered 1 through N. Find the number of trees while satisfying the following condition. Here, two trees T and T' are different if and only if there is a pair of vertices wh...
[ { "input": { "stdin": "4\n2 1 4 3" }, "output": { "stdout": "4" } }, { "input": { "stdin": "4\n3 4 1 2" }, "output": { "stdout": "4\n" } }, { "input": { "stdin": "4\n1 3 2 4" }, "output": { "stdout": "2\n" } }, { "in...
{ "tags": [], "title": "Invariant Tree" }
{ "cpp": "#include<bits/stdc++.h>\n\n#define pb push_back\n#define mp make_pair\n#define fi first\n#define se second\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair<int,int> pii;\ntypedef pair<ll,ll> pll;\n\ntemplate <typename T> bool chkmax(T &x,T y){return x<y?x=y,tru...
AIZU/p02226
# Test test UnionFind(バイナリ入力) Example Input Output
[ { "input": { "stdin": "" }, "output": { "stdout": "" } } ]
{ "tags": [], "title": "Test" }
{ "cpp": "#include <algorithm>\n#include <cassert>\n#include <cstdio>\n#include <iostream>\n#include <limits>\n#include <random>\n#include <utility>\n#include <vector>\n\nnamespace procon {\nclass UnionFind {\nprivate:\n struct nodeinfo {\n int par;\n int rank;\n nodeinfo(int par) : par(par), rank(0) {}\n ...
AIZU/p02377
# Minimum Cost Flow Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
[ { "input": { "stdin": "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1" }, "output": { "stdout": "6" } }, { "input": { "stdin": "" }, "output": { "stdout": "" } }, { "input": { "stdin": "6 5 2\n0 1 4 0\n0 2 0 -1\n1 3 2 1\n0 2 1 11\n2 2 2 1...
{ "tags": [], "title": "Minimum Cost Flow" }
{ "cpp": "#include <cassert>\n#include <iostream>\n#include <vector>\n#include <queue>\n#include <utility>\n#include <tuple>\n#include <limits>\nusing namespace std;\n\nstruct MinCostFlowGraph {\nprivate:\n using ll = long long;\n struct edge {\n int to;\n ll cap, cost;\n int r_idx;\n edge(int t, ll cap...