id
stringlengths
6
117
description
stringlengths
29
13k
code
stringlengths
9
465k
language
class label
4 classes
test_samples
dict
source
class label
5 classes
p00139 Snakes_38400
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. Class B ends w...
import java.util.Scanner; public class Main{ public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n; n = sc.nextInt(); for (int i = 0; i < n; i++) { String snake = sc.next(); String answer = "NA"; int index = 0; if (6 <= snake.length()) { if (snake.charAt(0) == '>...
4JAVA
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~", "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#===>~", "3\n>'======#======~\n>QQ=^=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#===>~", "3\n>(======#======~\n~~=Q=Q=Q=Q=Q=Q=Q=^=QQ>\n>'===#==~>=", "3\n>'======#======~\n>QQ=^=Q=Q=Q=Q=Q=Q=Q=~~\...
6AIZU
p00272 Ticket Sales_38401
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! Shortly after ...
c = [6000, 4000, 3000, 2000] for i in range(0,4): a, b = map(int, raw_input().split()) print c[a-1] * b
1Python2
{ "input": [ "3 10\n1 4\n4 1\n2 5", "3 10\n1 4\n4 1\n1 5", "3 13\n1 4\n4 1\n1 5", "3 13\n1 4\n1 1\n1 5", "3 13\n1 4\n1 2\n1 5", "2 13\n1 4\n1 2\n1 5", "2 13\n1 4\n1 2\n1 3", "2 13\n1 6\n1 2\n1 3", "3 10\n1 0\n4 1\n2 5", "3 10\n1 4\n2 1\n1 5", "3 16\n1 4\n1 1\n1 5", "3 1...
6AIZU
p00272 Ticket Sales_38402
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! Shortly after ...
#include <stdio.h> int main(void){ int t,n; int i; for(i=0;i<4;i++){ scanf("%d %d",&t,&n); if(t==1){ printf("%d\n",6000*n); } if(t==2){ printf("%d\n",4000*n); } if(t==3){ printf("%d\n",3000*n); } if(t==4){ printf("%d\n",2000*n); } } return 0; }
2C++
{ "input": [ "3 10\n1 4\n4 1\n2 5", "3 10\n1 4\n4 1\n1 5", "3 13\n1 4\n4 1\n1 5", "3 13\n1 4\n1 1\n1 5", "3 13\n1 4\n1 2\n1 5", "2 13\n1 4\n1 2\n1 5", "2 13\n1 4\n1 2\n1 3", "2 13\n1 6\n1 2\n1 3", "3 10\n1 0\n4 1\n2 5", "3 10\n1 4\n2 1\n1 5", "3 16\n1 4\n1 1\n1 5", "3 1...
6AIZU
p00272 Ticket Sales_38403
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! Shortly after ...
for i in range(4): t,n=map(int,input().split()) if t==1: print(f'{6000*n}') elif t==2: print(f'{4000*n}') elif t==3: print(f'{3000*n}') elif t==4: print(f'{2000*n}')
3Python3
{ "input": [ "3 10\n1 4\n4 1\n2 5", "3 10\n1 4\n4 1\n1 5", "3 13\n1 4\n4 1\n1 5", "3 13\n1 4\n1 1\n1 5", "3 13\n1 4\n1 2\n1 5", "2 13\n1 4\n1 2\n1 5", "2 13\n1 4\n1 2\n1 3", "2 13\n1 6\n1 2\n1 3", "3 10\n1 0\n4 1\n2 5", "3 10\n1 4\n2 1\n1 5", "3 16\n1 4\n1 1\n1 5", "3 1...
6AIZU
p00272 Ticket Sales_38404
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! Shortly after ...
import java.util.Scanner; public class Main{ public static void main(String[]args){ int ban; int su; int kin; int s=6000,a=4000,b=3000,c=2000; Scanner sc = new Scanner(System.in); for(int i=0;i<4;i++){ ban = sc.nextInt(); su = sc.nextInt(); switch(ban){ case 1: kin = s*su; System...
4JAVA
{ "input": [ "3 10\n1 4\n4 1\n2 5", "3 10\n1 4\n4 1\n1 5", "3 13\n1 4\n4 1\n1 5", "3 13\n1 4\n1 1\n1 5", "3 13\n1 4\n1 2\n1 5", "2 13\n1 4\n1 2\n1 5", "2 13\n1 4\n1 2\n1 3", "2 13\n1 6\n1 2\n1 3", "3 10\n1 0\n4 1\n2 5", "3 10\n1 4\n2 1\n1 5", "3 16\n1 4\n1 1\n1 5", "3 1...
6AIZU
p00460 Bingo_38405
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 one posi...
DIV = 100000 while 1: n, m, s = map(int, raw_input().split()) if n == 0: break dp = [[0]*(s+1) for i in range(n*n+1)] dp[0][0] = 1 for i in range(1, n*n+1): for j in range(s+1): if j - i >= 0: dp[i][j] = (dp[i][j] + dp[i-1][j-i] + dp[i][j-i]) % DIV if j - m - 1 >= 0: ...
1Python2
{ "input": [ "3 9 45\n3 100 50\n5 50 685\n0 0 0", "3 9 45\n3 100 50\n5 50 308\n0 0 0", "3 12 45\n3 100 75\n5 50 308\n0 0 0", "3 12 45\n3 100 69\n5 50 308\n0 0 0", "3 12 45\n3 100 69\n5 90 548\n0 0 0", "3 12 45\n3 100 50\n5 50 331\n0 0 0", "3 3 45\n3 100 69\n5 50 308\n0 0 0", "3 12 60\n...
6AIZU
p00460 Bingo_38406
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 one posi...
#include<cstdio> #include<cstring> #include<iostream> #include<vector> #include<algorithm> #include<string> using namespace std; int N,M,S; int dp[2][50][3001]; #define AMA (100000) int solve(){ memset(dp,0,sizeof(dp)); int now; int next; int ret = 0; dp[1][0][0]=1; for(int m=1;m<=M;m++){ now = m&1; ...
2C++
{ "input": [ "3 9 45\n3 100 50\n5 50 685\n0 0 0", "3 9 45\n3 100 50\n5 50 308\n0 0 0", "3 12 45\n3 100 75\n5 50 308\n0 0 0", "3 12 45\n3 100 69\n5 50 308\n0 0 0", "3 12 45\n3 100 69\n5 90 548\n0 0 0", "3 12 45\n3 100 50\n5 50 331\n0 0 0", "3 3 45\n3 100 69\n5 50 308\n0 0 0", "3 12 60\n...
6AIZU
p00460 Bingo_38407
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 one posi...
import itertools while 1: n,m,s=map(int,input().split()) if n==0:break dp=[[0 for _ in range(s+1)] for _ in range(n*n+1)] dp[0][0]=1 for i,j in itertools.product(range(1,n*n+1),range(s+1)): if j>=i:dp[i][j]+=dp[i-1][j-i]+dp[i][j-i] if j-m>=1:dp[i][j]+=100000-dp[i-1][j-m-1] dp...
3Python3
{ "input": [ "3 9 45\n3 100 50\n5 50 685\n0 0 0", "3 9 45\n3 100 50\n5 50 308\n0 0 0", "3 12 45\n3 100 75\n5 50 308\n0 0 0", "3 12 45\n3 100 69\n5 50 308\n0 0 0", "3 12 45\n3 100 69\n5 90 548\n0 0 0", "3 12 45\n3 100 50\n5 50 331\n0 0 0", "3 3 45\n3 100 69\n5 50 308\n0 0 0", "3 12 60\n...
6AIZU
p00460 Bingo_38408
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 one posi...
import static java.util.Arrays.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { static void tr(Object... os) { System.err.println(deepToString(os)); } sta...
4JAVA
{ "input": [ "3 9 45\n3 100 50\n5 50 685\n0 0 0", "3 9 45\n3 100 50\n5 50 308\n0 0 0", "3 12 45\n3 100 75\n5 50 308\n0 0 0", "3 12 45\n3 100 69\n5 50 308\n0 0 0", "3 12 45\n3 100 69\n5 90 548\n0 0 0", "3 12 45\n3 100 50\n5 50 331\n0 0 0", "3 3 45\n3 100 69\n5 50 308\n0 0 0", "3 12 60\n...
6AIZU
p00650 The House of Huge Family_38409
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 of the house is as large as...
#include <bits/stdc++.h> using namespace std; #define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl #define repi(i,a,b) for(int i=int(a);i<int(b);i++) #define peri(i,a,b) for(int i=int(b);i-->int(a);) #define rep(i,n) repi(i,0,n) #define per(i,n) peri(i,0,n) #define all(c) begin(c),end(c) #define mp mak...
2C++
{ "input": [ "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", "3 2\n0 1 2\n1 2 1\n2 1\n0 1 100\n2 1\n0 0 0\n2 1\n0 1 -1\n0 0", "3 2\n0 1 2\n1 2 1\n2 1\n1 1 100\n2 1\n0 0 0\n2 1\n0 1 -1\n0 0", "3 2\n0 2 2\n0 2 1\n2 1\n0 1 100\n2 1\n0 1 0\n2 1\n0 1 -1\n0 0", "3 2\n0 1 2\n1 2 1\n2 1\n...
6AIZU
p00650 The House of Huge Family_38410
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 of the house is as large as...
# AOJ 1065 The House of Huge Family # Python3 2018.7.10 bal4u # UNION-FIND library class UnionSet: def __init__(self, nmax): self.size = [1]*nmax self.id = [i for i in range(nmax+1)] def root(self, i): while i != self.id[i]: self.id[i] = self.id[self.id[i]] i = self.id[i] return i def connected(self, ...
3Python3
{ "input": [ "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", "3 2\n0 1 2\n1 2 1\n2 1\n0 1 100\n2 1\n0 0 0\n2 1\n0 1 -1\n0 0", "3 2\n0 1 2\n1 2 1\n2 1\n1 1 100\n2 1\n0 0 0\n2 1\n0 1 -1\n0 0", "3 2\n0 2 2\n0 2 1\n2 1\n0 1 100\n2 1\n0 1 0\n2 1\n0 1 -1\n0 0", "3 2\n0 1 2\n1 2 1\n2 1\n...
6AIZU
p00650 The House of Huge Family_38411
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 of the house is as large as...
import java.util.Arrays; import java.util.Scanner; public class Main { static Scanner sc = new Scanner(System.in); static int N, M, E; static int[] from; static long[] cost; static boolean disjoint() { UnionFind uf = new UnionFind(N); for (int i = 0; i < N; ++i) { if (from[i] != -1) uf.union(i, from[i]);...
4JAVA
{ "input": [ "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", "3 2\n0 1 2\n1 2 1\n2 1\n0 1 100\n2 1\n0 0 0\n2 1\n0 1 -1\n0 0", "3 2\n0 1 2\n1 2 1\n2 1\n1 1 100\n2 1\n0 0 0\n2 1\n0 1 -1\n0 0", "3 2\n0 2 2\n0 2 1\n2 1\n0 1 100\n2 1\n0 1 0\n2 1\n0 1 -1\n0 0", "3 2\n0 1 2\n1 2 1\n2 1\n...
6AIZU
p00795 Co-occurrence Search_38412
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 keyword search algorithms. Fo...
#include <iostream> #include <cstring> #include <climits> using namespace std; void solve(string s,string key){ int left = 0, right = 0; int n = s.length(), m = key.length(); int minLen = INT_MAX, cnt = 0; string minStr = ""; int level[256]; bool flg[256]; memset(flg,0,sizeof(flg)); memset(level,0,siz...
2C++
{ "input": [ "Thefirstexampleistrivial.\n\nmfv\n\nAhugeamountofinformationisbeingheapedonWWW.Albeititisnot\nwell-organized,userscanbrowseWWWasanunboundedsourceof\nup-to-dateinformation,insteadofconsultingestablishedbutalittle\nout-of-dateencyclopedia.However,youcanfurtherexploitWWWby\nlearningmoreaboutkeywordsear...
6AIZU
p00795 Co-occurrence Search_38413
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 keyword search algorithms. Fo...
import java.util.Arrays; import java.util.Scanner; public class Main { static Scanner sc = new Scanner(System.in); static int[] key = new int[256]; public static void main(String[] args) { while (true) { StringBuilder sb = new StringBuilder(); while (true) { String line = sc.nextLine(); if (line.i...
4JAVA
{ "input": [ "Thefirstexampleistrivial.\n\nmfv\n\nAhugeamountofinformationisbeingheapedonWWW.Albeititisnot\nwell-organized,userscanbrowseWWWasanunboundedsourceof\nup-to-dateinformation,insteadofconsultingestablishedbutalittle\nout-of-dateencyclopedia.However,youcanfurtherexploitWWWby\nlearningmoreaboutkeywordsear...
6AIZU
p00926 Shopping_38414
Example Input 10 3 3 7 8 9 2 5 Output 23
N, m = map(int, raw_input().split()) three = [False]*N for loop in xrange(m): c, d = map(int, raw_input().split()) if c < d: three[c:d] = [True]*len(three[c:d]) ans = 0 for i in xrange(N): ans += 1 if three[i]: ans += 2 print ans+1
1Python2
{ "input": [ "10 3\n3 7\n8 9\n2 5", "10 3\n3 7\n8 9\n3 5", "10 3\n3 7\n8 9\n3 8", "10 3\n2 8\n8 9\n3 8", "10 3\n3 7\n8 9\n1 8", "9 3\n3 7\n8 9\n1 5", "10 3\n3 10\n8 9\n1 5", "10 3\n3 4\n8 9\n4 5", "18 3\n3 7\n7 9\n2 5", "18 3\n3 7\n7 9\n1 5", "18 3\n3 7\n7 17\n1 5", "15...
6AIZU
p00926 Shopping_38415
Example Input 10 3 3 7 8 9 2 5 Output 23
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int n,m; cin >> n >> m; vector<int> after(n+2, 0); for(int i=0; i<m; i++){ int c,d; cin >> c >> d; after[c] = max(after[c], d); } int ans = 0; int farthest = 0; for(int i=0; i<=n; i++){ farthest = max(farthest, ...
2C++
{ "input": [ "10 3\n3 7\n8 9\n2 5", "10 3\n3 7\n8 9\n3 5", "10 3\n3 7\n8 9\n3 8", "10 3\n2 8\n8 9\n3 8", "10 3\n3 7\n8 9\n1 8", "9 3\n3 7\n8 9\n1 5", "10 3\n3 10\n8 9\n1 5", "10 3\n3 4\n8 9\n4 5", "18 3\n3 7\n7 9\n2 5", "18 3\n3 7\n7 9\n1 5", "18 3\n3 7\n7 17\n1 5", "15...
6AIZU
p00926 Shopping_38416
Example Input 10 3 3 7 8 9 2 5 Output 23
import sys reader=(token for line in sys.stdin for token in line.split()) while 1: try: n=int(next(reader)) m=int(next(reader)) except: break a=[1]*(n+1) for i in range(m): c=int(next(reader))-1 d=int(next(reader))-1 for i in range(c,d): a[i]=3 print(sum(a))
3Python3
{ "input": [ "10 3\n3 7\n8 9\n2 5", "10 3\n3 7\n8 9\n3 5", "10 3\n3 7\n8 9\n3 8", "10 3\n2 8\n8 9\n3 8", "10 3\n3 7\n8 9\n1 8", "9 3\n3 7\n8 9\n1 5", "10 3\n3 10\n8 9\n1 5", "10 3\n3 4\n8 9\n4 5", "18 3\n3 7\n7 9\n2 5", "18 3\n3 7\n7 9\n1 5", "18 3\n3 7\n7 17\n1 5", "15...
6AIZU
p00926 Shopping_38417
Example Input 10 3 3 7 8 9 2 5 Output 23
import java.io.*; import java.math.BigDecimal; import java.util.*; public class Main { static int INF = 2 << 27; static int[] vx = {1,0,-1,0}; static int[] vy = {0,1,0,-1}; public static void main(String[] args) { //FastScanner sc = new FastScanner(); Scanner sc = new Scanner(System.in); PrintWriter out = n...
4JAVA
{ "input": [ "10 3\n3 7\n8 9\n2 5", "10 3\n3 7\n8 9\n3 5", "10 3\n3 7\n8 9\n3 8", "10 3\n2 8\n8 9\n3 8", "10 3\n3 7\n8 9\n1 8", "9 3\n3 7\n8 9\n1 5", "10 3\n3 10\n8 9\n1 5", "10 3\n3 4\n8 9\n4 5", "18 3\n3 7\n7 9\n2 5", "18 3\n3 7\n7 9\n1 5", "18 3\n3 7\n7 17\n1 5", "15...
6AIZU
p01059 Gossip_38418
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 have secret i...
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<map> #include<set> #include<utility> #include<cmath> #include<cstring> #include<queue> #include<cstdio> #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,a) loop(i,0,a) #define pb push_back #define mp make_pair #define all(in) in.be...
2C++
{ "input": [ "10 3\n2 5 7", "100000 1\n1", "10 5\n2 5 6 8 10", "3 2\n1 3", "10 3\n2 5 8", "10 3\n3 5 7", "100001 1\n1", "110001 1\n1", "10 1\n2 2 8", "3 1\n2 2 12", "1 1\n1 3 12", "10 3\n2 5 6 8 10", "10 1\n1 4 8", "8 1\n2 2 7", "10 1\n3 0 8", "17 2\n2 2...
6AIZU
p01059 Gossip_38419
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 have secret i...
n, m = map(int, input().split()) a =list(map(int, input().split())) t = max(a[0] - 1, n - a[-1]) for i in range(1, m):t = max(t, (a[i] - a[i - 1]) // 2) print(t)
3Python3
{ "input": [ "10 3\n2 5 7", "100000 1\n1", "10 5\n2 5 6 8 10", "3 2\n1 3", "10 3\n2 5 8", "10 3\n3 5 7", "100001 1\n1", "110001 1\n1", "10 1\n2 2 8", "3 1\n2 2 12", "1 1\n1 3 12", "10 3\n2 5 6 8 10", "10 1\n1 4 8", "8 1\n2 2 7", "10 1\n3 0 8", "17 2\n2 2...
6AIZU
p01059 Gossip_38420
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 have secret i...
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.NoSuchElementException; public class Main{ int N,M; int[] a; public void solve() { N = nextInt(); M = nextInt(); a = new int[M]; for(int i = 0;i < M;i++)a[i] = nextInt(); int ans = 0; for(int i = 0;i <= ...
4JAVA
{ "input": [ "10 3\n2 5 7", "100000 1\n1", "10 5\n2 5 6 8 10", "3 2\n1 3", "10 3\n2 5 8", "10 3\n3 5 7", "100001 1\n1", "110001 1\n1", "10 1\n2 2 8", "3 1\n2 2 12", "1 1\n1 3 12", "10 3\n2 5 6 8 10", "10 1\n1 4 8", "8 1\n2 2 7", "10 1\n3 0 8", "17 2\n2 2...
6AIZU
p01191 Grated Radish_38421
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 from the microco...
#include <stdio.h> #include <math.h> #include <iostream> #include <complex> #include <vector> #include <utility> #include <algorithm> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define mp make_pair const double EPS = 1e-12; const double pi = atan2(0.0, -1.0); typedef complex<double> P; d...
2C++
{ "input": [ "2\n1 2\n1\n42 3.141592653589793\n5 20\n3\n0 307.09242465218927\n180 307.09242465218927\n90 728.30573874452591", "2\n1 2\n1\n66 3.141592653589793\n5 20\n3\n0 307.09242465218927\n180 307.09242465218927\n90 728.30573874452591", "2\n1 2\n1\n110 3.141592653589793\n9 20\n3\n0 307.09242465218927\n1...
6AIZU
p01329 Stolen Jewel_38422
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 has not complete...
#include<iostream> #include<string> #include<queue> #include<algorithm> #include<set> using namespace std; #define rep(i,n) for ( int i = 0; i < n; i++) static const int MAX = 50; static const int PMAX = 11; static const string DT = "URDL"; static const int di[4] = {-1, 0, 1, 0}; static const int dj[4] = {0, 1, 0, -1};...
2C++
{ "input": [ "6 7\n.......\n...#...\n...#.S.\n...###.\n.G.....\n.......\n2\nLL\nDD", "7 6\n......\n.####.\n.####.\n...S#.\n...##.\n...##.\n.....G\n3\nLD\nDD\nLLL\n7 8\nS#......\n.#.####.\n.#.#G.#.\n.#.##.#.\n.#....#.\n.######.\n........\n8\nDDDD\nDDDU\nUUUU\nUUUD\nRRRR\nRRRL\nLLLL\nLLLR\n3 8\n\nS......G\n\n2\...
6AIZU
p01329 Stolen Jewel_38423
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 has not complete...
import java.util.*; class State{ char x, y; short cost; String path; char[] match; State(char x, char y, short cost, String path, char[] match){ this.x = x; this.y = y; this.cost = cost; this.path = path; this.match = match; } public boolean equals(Object o){ State st = (State)o...
4JAVA
{ "input": [ "6 7\n.......\n...#...\n...#.S.\n...###.\n.G.....\n.......\n2\nLL\nDD", "7 6\n......\n.####.\n.####.\n...S#.\n...##.\n...##.\n.....G\n3\nLD\nDD\nLLL\n7 8\nS#......\n.#.####.\n.#.#G.#.\n.#.##.#.\n.#....#.\n.######.\n........\n8\nDDDD\nDDDU\nUUUU\nUUUD\nRRRR\nRRRL\nLLLL\nLLLR\n3 8\n\nS......G\n\n2\...
6AIZU
p01496 Bicube_38424
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 square. She is...
#include <iostream> #include <iomanip> #include <sstream> #include <cstdio> #include <string> #include <vector> #include <algorithm> #include <complex> #include <cstring> #include <cstdlib> #include <cmath> #include <cassert> #include <climits> #include <queue> #include <set> #include <map> #include <valarray> #include...
2C++
{ "input": [ "3 40\n.a....a....a....a....f....f....f....f...\nbc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.#eb#.\n.#....#....#....#....#....#....#....#...", "3 40\n.a....a....a....a....f....f....f....f...\nbc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.#be#.\n.#....#....#....#....#....#....#....#...", "3 40\n.a....a....a....a......
6AIZU
p01496 Bicube_38425
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 square. She is...
from collections import deque from string import ascii_lowercase, ascii_uppercase, digits import sys readline = sys.stdin.readline write = sys.stdout.write D = [ (1, 5, 2, 3, 0, 4), # 'U' (3, 1, 0, 5, 4, 2), # 'R' (4, 0, 2, 3, 5, 1), # 'D' (2, 1, 5, 0, 4, 3), # 'L' ] p_dice = (0, 0, 0, 1, 1, 2, 2, 3)*3...
3Python3
{ "input": [ "3 40\n.a....a....a....a....f....f....f....f...\nbc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.#eb#.\n.#....#....#....#....#....#....#....#...", "3 40\n.a....a....a....a....f....f....f....f...\nbc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.#be#.\n.#....#....#....#....#....#....#....#...", "3 40\n.a....a....a....a......
6AIZU
p01496 Bicube_38426
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 square. She is...
import java.util.*; class Main{ int h,w; char[][] sheet; ArrayList<Dice> list; ArrayList<Character> color; int[] colors; int[] dx = {0, 1, 0, -1}; int[] dy = {-1, 0, 1, 0}; int[][] nei = {{1, 3, 2, 4}, {5, 3, 0, 4}, {0, 3, 5, 4}, ...
4JAVA
{ "input": [ "3 40\n.a....a....a....a....f....f....f....f...\nbc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.#eb#.\n.#....#....#....#....#....#....#....#...", "3 40\n.a....a....a....a....f....f....f....f...\nbc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.#be#.\n.#....#....#....#....#....#....#....#...", "3 40\n.a....a....a....a......
6AIZU
p01664 Sigma_38427
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 internally ...
#include<stdio.h> #include<algorithm> using namespace std; int p[500]; int q[250][500]; int r[250][500]; int ret[500]; int s[500]; int t[250][500]; int u[500]; int v[250][500]; int w[250][500]; int ABS(int a){return max(a,-a);} int LIM=240; int main(){ int a; scanf("%d",&a); for(int i=0;i<a;i++)p[i]=i; for(int i=0;...
2C++
{ "input": [ "" ], "output": [ "" ] }
6AIZU
p01809 Let's Solve Geometric Problems_38428
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 decimal numbers. For example, 0.1 in...
#include <bits/stdc++.h> using namespace std; using VI = vector<int>; using VVI = vector<VI>; using PII = pair<int, int>; using LL = long long; using VL = vector<LL>; using VVL = vector<VL>; using PLL = pair<LL, LL>; using VS = vector<string>; #define ALL(a) begin((a)),end((a)) #define RALL(a) (a).rbegin(), (a).rend...
2C++
{ "input": [ "1 2", "1 3", "1 6", "3 2", "4 5", "3 10", "3 14", "2 14", "2 17", "3 11", "2 39", "2 13", "3 19", "2 15", "3 38", "3 23", "2 31", "3 55", "3 29", "1 42", "2 35", "2 41", "3 26", "3 47", "2 65", "1 30"...
6AIZU
p01809 Let's Solve Geometric Problems_38429
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 decimal numbers. For example, 0.1 in...
def gcd(m, n): r = m % n return gcd(n, r) if r else n p, q = map(int, input().split()) q //= gcd(p, q) x = q; y = 1; k = 2 while k*k <= x: if x % k == 0: while x % k == 0: x //= k y *= k k += 1 y *= x print(y)
3Python3
{ "input": [ "1 2", "1 3", "1 6", "3 2", "4 5", "3 10", "3 14", "2 14", "2 17", "3 11", "2 39", "2 13", "3 19", "2 15", "3 38", "3 23", "2 31", "3 55", "3 29", "1 42", "2 35", "2 41", "3 26", "3 47", "2 65", "1 30"...
6AIZU
p01809 Let's Solve Geometric Problems_38430
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 decimal numbers. For example, 0.1 in...
import java.io.PrintWriter; import java.util.*; public class Main { private static long gcd(long a, long b) { if ( a== 0)return b; return gcd(b % a, a); } public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System...
4JAVA
{ "input": [ "1 2", "1 3", "1 6", "3 2", "4 5", "3 10", "3 14", "2 14", "2 17", "3 11", "2 39", "2 13", "3 19", "2 15", "3 38", "3 23", "2 31", "3 55", "3 29", "1 42", "2 35", "2 41", "3 26", "3 47", "2 65", "1 30"...
6AIZU
p01944 Almost Infinite Glico_38431
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 times in a row according ...
#include<bits/stdc++.h> using namespace std; // macro #define rep(i,n) for(i=0;i<n;i++) #define ll long long #define all(v) v.begin(), v.end() // code starts #define MOD 1000000007 int main() { ll n,m,k;cin>>n>>m>>k; vector<int> p(m); ll i,j,l; rep(i,m)cin>>p[i]; ll num=1; ll needs=0; while(num<=k) {...
2C++
{ "input": [ "10 3 2\n3\n6\n6", "10 3 2\n3\n10\n6", "10 3 2\n3\n10\n9", "11 3 2\n3\n10\n9", "11 3 2\n3\n17\n9", "11 3 2\n3\n17\n16", "11 2 2\n3\n17\n16", "11 1 2\n3\n17\n16", "7 3 2\n3\n6\n6", "10 3 2\n3\n16\n6", "2 3 2\n3\n10\n9", "11 3 2\n6\n17\n16", "2 2 2\n3\n17...
6AIZU
p01944 Almost Infinite Glico_38432
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 times in a row according ...
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class Main { static InputStream is; static PrintWriter out; static String INPUT = ""; static void solve() { int n = ...
4JAVA
{ "input": [ "10 3 2\n3\n6\n6", "10 3 2\n3\n10\n6", "10 3 2\n3\n10\n9", "11 3 2\n3\n10\n9", "11 3 2\n3\n17\n9", "11 3 2\n3\n17\n16", "11 2 2\n3\n17\n16", "11 1 2\n3\n17\n16", "7 3 2\n3\n6\n6", "10 3 2\n3\n16\n6", "2 3 2\n3\n10\n9", "11 3 2\n6\n17\n16", "2 2 2\n3\n17...
6AIZU
p02093 Invariant Tree_38433
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 where T has an edge ...
#include<bits/stdc++.h> #define pb push_back #define mp make_pair #define fi first #define se second using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<ll,ll> pll; template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;} template <typena...
2C++
{ "input": [ "4\n2 1 4 3", "4\n3 2 4 1", "4\n2 1 3 4", "4\n1 2 3 4", "4\n3 1 4 2", "4\n4 3 2 1", "4\n1 2 4 3", "4\n1 3 2 4", "4\n1 3 4 2", "4\n1 4 2 3", "4\n1 4 3 2", "4\n3 1 2 4", "4\n4 1 3 2", "4\n4 1 2 3", "4\n2 4 3 1", "4\n3 2 1 4", "4\n2 3 1 4",...
6AIZU
p02226 Test_38434
test UnionFind(バイナリ入力) Example Input Output
#include <algorithm> #include <cassert> #include <cstdio> #include <iostream> #include <limits> #include <random> #include <utility> #include <vector> namespace procon { class UnionFind { private: struct nodeinfo { int par; int rank; nodeinfo(int par) : par(par), rank(0) {} }; std::vector<nodeinfo> n...
2C++
{ "input": [ "" ], "output": [ "" ] }
6AIZU
p02377 Minimum Cost Flow_38435
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
#include <bits/stdc++.h> using namespace std; struct SuccessiveShortestPath { struct Edge{ int to, cap, cost, rev; }; int n, init; vector<vector<Edge>> g; vector<int> dist, pv, pe, h; SuccessiveShortestPath() {} SuccessiveShortestPath(int n, int INF = 1e9) : n(n), g(n), init(INF), dist(n), pv(n), pe(n...
2C++
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "", "4 5 2\n0 0 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "4 5 2\n0 1 2 0\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "4 5 2\n0 1 2 0\n0 2 1 2\n1 2 2 1\n0 3 1 3\n2 3 2 1", "4 5 3\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "4 ...
6AIZU
p02377 Minimum Cost Flow_38436
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
# ノードをtupleで渡す from collections import defaultdict from heapq import * class MinCostFlow: def __init__(self): self.inf=10**9 self.to = defaultdict(dict) def add_edge(self, u, v, cap, cost): self.to[u][v]=[cap, cost] self.to[v][u]=[0, -cost] # s...source,t...sink,f...flow ...
3Python3
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "", "4 5 2\n0 0 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "4 5 2\n0 1 2 0\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "4 5 2\n0 1 2 0\n0 2 1 2\n1 2 2 1\n0 3 1 3\n2 3 2 1", "4 5 3\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "4 ...
6AIZU
p02377 Minimum Cost Flow_38437
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
import java.util.*; public class Main implements Runnable { private static int MOD = 1_000_000_007; public static void main(String[] args) { // Run with 32MB stack Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024); thread.start(); } @Override public void ...
4JAVA
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "", "4 5 2\n0 0 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "4 5 2\n0 1 2 0\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "4 5 2\n0 1 2 0\n0 2 1 2\n1 2 2 1\n0 3 1 3\n2 3 2 1", "4 5 3\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "4 ...
6AIZU