problem_id
int64
0
1.52k
problem_name
stringlengths
5
112
description
stringlengths
209
6.47k
lang
stringclasses
4 values
code
stringlengths
7
95.5k
status
stringclasses
3 values
passed
int64
0
24
total
int64
0
25
error
stringclasses
567 values
failures
stringlengths
2
2k
source
stringclasses
5 values
difficulty
stringclasses
13 values
392
p03225 Tenka1 Programmer Contest - Equilateral
There are some coins in the xy-plane. The positions of the coins are represented by a grid of characters with H rows and W columns. If the character at the i-th row and j-th column, s_{ij}, is `#`, there is one coin at point (i,j); if that character is `.`, there is no coin at point (i,j). There are no other coins in t...
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; ll solve(const vector<string>& s, ll& hoge) { int H = s.size(); int W = s.front().size(); vector< vector<int> > sum(H + W - 1, vector<int>(H + 1, 0)); for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { su...
partial
1
3
[{"idx": 1, "reason": "wrong_answer", "expected": "870", "got": "765"}, {"idx": 2, "reason": "wrong_answer", "expected": "3", "got": "0"}]
atcoder
UNKNOWN
392
p03225 Tenka1 Programmer Contest - Equilateral
There are some coins in the xy-plane. The positions of the coins are represented by a grid of characters with H rows and W columns. If the character at the i-th row and j-th column, s_{ij}, is `#`, there is one coin at point (i,j); if that character is `.`, there is no coin at point (i,j). There are no other coins in t...
cpp
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <str...
partial
1
3
[{"idx": 1, "reason": "wrong_answer", "expected": "870", "got": "1017"}, {"idx": 2, "reason": "wrong_answer", "expected": "3", "got": "4"}]
atcoder
UNKNOWN
392
p03225 Tenka1 Programmer Contest - Equilateral
There are some coins in the xy-plane. The positions of the coins are represented by a grid of characters with H rows and W columns. If the character at the i-th row and j-th column, s_{ij}, is `#`, there is one coin at point (i,j); if that character is `.`, there is no coin at point (i,j). There are no other coins in t...
python3
H,W=map(int,input().split()) S=[list(input()) for i in range(H)] table=[[0]*(H+W-1) for i in range(H+W-1)] for j in range(H): for i in range(W): if S[j][i]=='#': table[i+j][i-j+H-1]=1 yoko=[[0]*(H+W) for i in range(H+W-1)] for j in range(H+W-1): for i in range(1,H+W): yoko[j][i]=...
partial
1
3
[{"idx": 1, "reason": "runtime_error", "rc": 1, "stderr": "Traceback (most recent call last):\n File \"/tmp/sbx_kutkd_oz/tmp73omvdg9.py\", line 6, in <module>\n if S[j][i]=='#':\n ~~~~^^^\nIndexError: list index out of range\n", "stdout_tail": ""}, {"idx": 2, "reason": "runtime_error", "rc": 1, "stderr": "Tra...
atcoder
UNKNOWN
392
p03225 Tenka1 Programmer Contest - Equilateral
There are some coins in the xy-plane. The positions of the coins are represented by a grid of characters with H rows and W columns. If the character at the i-th row and j-th column, s_{ij}, is `#`, there is one coin at point (i,j); if that character is `.`, there is no coin at point (i,j). There are no other coins in t...
java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int h = sc.nextInt(); int w = sc.nextInt(); int[][] map = new int[h+2000][w+2000]; for(int i=0; i<h; i++){ String s = sc.next(); for(...
partial
1
3
[{"idx": 1, "reason": "runtime_error", "rc": 1, "stderr": "Exception in thread \"main\" java.lang.StringIndexOutOfBoundsException: String index out of range: 14\n\tat java.base/java.lang.StringLatin1.charAt(StringLatin1.java:48)\n\tat java.base/java.lang.String.cha", "stdout_tail": ""}, {"idx": 2, "reason": "runtime_er...
atcoder
UNKNOWN
392
p03225 Tenka1 Programmer Contest - Equilateral
There are some coins in the xy-plane. The positions of the coins are represented by a grid of characters with H rows and W columns. If the character at the i-th row and j-th column, s_{ij}, is `#`, there is one coin at point (i,j); if that character is `.`, there is no coin at point (i,j). There are no other coins in t...
java
import java.util.ArrayList; import java.util.List; public class Main { private static void solve() { int h = ni(); int w = ni(); int nh = h + w; int nw = h + w; List<int[]> list = new ArrayList<>(); int[][] map = new int[nh][nw]; for (int i = 0; i < h; i++) { char[] s = ns(); ...
partial
1
3
[{"idx": 1, "reason": "wrong_answer", "expected": "870", "got": ""}, {"idx": 2, "reason": "wrong_answer", "expected": "3", "got": ""}]
atcoder
UNKNOWN
392
p03225 Tenka1 Programmer Contest - Equilateral
There are some coins in the xy-plane. The positions of the coins are represented by a grid of characters with H rows and W columns. If the character at the i-th row and j-th column, s_{ij}, is `#`, there is one coin at point (i,j); if that character is `.`, there is no coin at point (i,j). There are no other coins in t...
python3
H, W = map(int, input().split()) I = [input() for _ in range(H)] X = [[[0, 1][a=="#"] for a in inp] for inp in I] k = 32 def r(): global H, W, I I = ["".join([I[H - 1 - j][i] for j in range(H)]) for i in range(W)] H, W = W, H def st1(s): return int(s.replace("#", "1" * k).replace(".", "0" * k), 2) def s...
partial
1
3
[{"idx": 1, "reason": "runtime_error", "rc": 1, "stderr": "Traceback (most recent call last):\n File \"/tmp/sbx_q8s70qlt/tmpblu7jrgo.py\", line 21, in <module>\n A2 = [st1(\"\".join([I[i][j] for i in range(H)])) for j in range(W)]\n ~~~~^^^", "stdout_tail": ""}, {"idx": 2, "reason": "runtime_e...
atcoder
UNKNOWN
392
p03225 Tenka1 Programmer Contest - Equilateral
There are some coins in the xy-plane. The positions of the coins are represented by a grid of characters with H rows and W columns. If the character at the i-th row and j-th column, s_{ij}, is `#`, there is one coin at point (i,j); if that character is `.`, there is no coin at point (i,j). There are no other coins in t...
python3
from itertools import accumulate h, w = map(int, input().split()) field = [input() for _ in range(h)] l = max(h, w) precalc_rd = [] precalc_ld = [] for ij in range(h + w - 1): coins = [0] * (l + 1) min_i = max(0, ij - w + 1) max_i = ij - max(0, ij - h + 1) offset = (min_i - (ij - min_i) + w - 1) // 2 ...
partial
1
3
[{"idx": 1, "reason": "runtime_error", "rc": 1, "stderr": "Traceback (most recent call last):\n File \"/tmp/sbx_mpksqpzm/tmpvs7jv8ss.py\", line 17, in <module>\n if field[i][j] == '#':\n ~~~~~~~~^^^\nIndexError: string index out of range\n", "stdout_tail": ""}, {"idx": 2, "reason": "runtime_error", "rc": 1, "...
atcoder
UNKNOWN
399
p00395 Maze and Items
Maze & Items is a puzzle game in which the player tries to reach the goal while collecting items. The maze consists of $W \times H$ grids, and some of them are inaccessible to the player depending on the items he/she has now. The score the player earns is defined according to the order of collecting items. The objectiv...
cpp
#include <iostream> #include <queue> using namespace std; int H, W, sx[32], sy[32], s[10][10], idx[1009][1009]; char c[1009][1009]; int t[32][32], u[1009][1009]; pair<int, int> dp[1 << 10][32]; int dx[4] = { 1, 0, -1, 0 }; int dy[4] = { 0, 1, 0, -1 }; int main() { cin >> W >> H; for (int i = 1; i <= H; i++) { fo...
partial
1
4
[{"idx": 1, "reason": "wrong_answer", "expected": "-1", "got": "17 0"}, {"idx": 2, "reason": "wrong_answer", "expected": "53 19", "got": "-1"}, {"idx": 3, "reason": "wrong_answer", "expected": "31 0", "got": "16 0"}]
aizu
UNKNOWN
399
p00395 Maze and Items
Maze & Items is a puzzle game in which the player tries to reach the goal while collecting items. The maze consists of $W \times H$ grids, and some of them are inaccessible to the player depending on the items he/she has now. The score the player earns is defined according to the order of collecting items. The objectiv...
cpp
#include<iostream> #include<vector> #include<algorithm> #include<queue> using namespace std; using lint = long long; using P = pair<int, int>; using LLP = pair<long long, long long>; const long long LLINF = 1LL << 61; const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1}; template<typename T> bool chmax(T &a, T b){...
partial
1
4
[{"idx": 1, "reason": "wrong_answer", "expected": "-1", "got": "17 0"}, {"idx": 2, "reason": "wrong_answer", "expected": "53 19", "got": "52 19"}, {"idx": 3, "reason": "wrong_answer", "expected": "31 0", "got": "-1"}]
aizu
UNKNOWN
399
p00395 Maze and Items
Maze & Items is a puzzle game in which the player tries to reach the goal while collecting items. The maze consists of $W \times H$ grids, and some of them are inaccessible to the player depending on the items he/she has now. The score the player earns is defined according to the order of collecting items. The objectiv...
cpp
#include<bits/stdc++.h> typedef long long int ll; typedef unsigned long long int ull; #define BIG_NUM 2000000000 #define HUGE_NUM 99999999999999999 #define MOD 1000000007 #define EPS 0.000000001 using namespace std; #define NUM 1005 #define EMPTY 10 struct Loc{ int row,col; }; struct Data{ Loc loc; char ch; }; ...
compile_error
0
0
COMPILE_ERROR:/tmp/sbx_s528hh5f/tmp68s3ejpq.cpp: In function ‘int main()’: /tmp/sbx_s528hh5f/tmp68s3ejpq.cpp:94:33: error: reference to ‘data’ is ambiguous 94 | data[index].ch = base_map[row][col]; | ^~~~ In file included from /usr/include/c++/11/...
[]
aizu
UNKNOWN
404
p01458 Kth Sentence
A student, Kita_masa, is taking an English examination. In this examination, he has to write a sentence of length m. Since he completely forgot the English grammar, he decided to consider all sentences of length m constructed by concatenating the words he knows and write the K-th sentence among the candidates sorted i...
cpp
//84104971101048411497 - Can you guess what does this mean? #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef complex<double> point; #define mapii map<int, int> #define debug(a) cout << #a << ": " << a << endl #define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl #define fd...
all_fail
0
3
[{"idx": 0, "reason": "runtime_error", "rc": -11, "stderr": "", "stdout_tail": ""}, {"idx": 1, "reason": "runtime_error", "rc": -11, "stderr": "", "stdout_tail": ""}, {"idx": 2, "reason": "runtime_error", "rc": -11, "stderr": "", "stdout_tail": ""}]
aizu
UNKNOWN
419
1148_C. Crazy Diamond
You are given a permutation p of integers from 1 to n, where n is an even number. Your goal is to sort the permutation. To do so, you can perform zero or more operations of the following type: * take two indices i and j such that 2 ⋅ |i - j| ≥ n and swap p_i and p_j. There is no need to minimize the number of...
cpp
#include <bits/stdc++.h> using namespace std; const long long maxn = (long long)3e5 + 7; long long a[maxn]; long long b[maxn]; long long pos[maxn]; struct node { long long x, y; } ans[maxn * 5]; signed main() { ios::sync_with_stdio(false); long long n; cin >> n; for (long long i = 1; i <= n; i++) cin >> a[i];...
partial
4
15
[{"idx": 2, "reason": "wrong_answer", "expected": "5\n1 6\n2 6\n1 6\n1 5\n1 4", "got": "9\n1 4\n4 1\n2 6\n1 6\n2 6\n4 1\n4 1\n5 1\n4 1"}, {"idx": 3, "reason": "wrong_answer", "expected": "17\n3 10\n10 2\n5 10\n10 3\n7 1\n1 10\n10 4\n6 1\n1 10\n10 5\n7 1\n1 6\n9 1\n1 7\n9 1\n1 8\n1 10", "got": "25\n1 10\n2 10\n1 10\n2 1...
codeforces
C
419
1148_C. Crazy Diamond
You are given a permutation p of integers from 1 to n, where n is an even number. Your goal is to sort the permutation. To do so, you can perform zero or more operations of the following type: * take two indices i and j such that 2 ⋅ |i - j| ≥ n and swap p_i and p_j. There is no need to minimize the number of...
java
import java.io.*; import java.util.*; import java.util.concurrent.ThreadLocalRandom; public class Main { public static void main(String[] args) throws FileNotFoundException { ConsoleIO io = new ConsoleIO(new InputStreamReader(System.in), new PrintWriter(System.out)); // String fileName = "C-large-p...
partial
1
15
[{"idx": 0, "reason": "wrong_answer", "expected": "1\n1 2", "got": "1\n2 1"}, {"idx": 1, "reason": "wrong_answer", "expected": "2\n1 3\n2 4", "got": "2\n3 1\n4 2"}, {"idx": 2, "reason": "wrong_answer", "expected": "5\n1 6\n2 6\n1 6\n1 5\n1 4", "got": "9\n4 1\n4 1\n1 6\n6 2\n5 1\n1 4\n6 1\n1 5\n1 6"}, {"idx": 3, "reason...
codeforces
C
419
1148_C. Crazy Diamond
You are given a permutation p of integers from 1 to n, where n is an even number. Your goal is to sort the permutation. To do so, you can perform zero or more operations of the following type: * take two indices i and j such that 2 ⋅ |i - j| ≥ n and swap p_i and p_j. There is no need to minimize the number of...
cpp
#include <bits/stdc++.h> using namespace std; const int MAX_N = (int)3e5 + 5; int N, P[MAX_N], loc[MAX_N]; vector<pair<int, int> > ans; void solve(int x) { int idx = loc[x]; while (x != idx) { int idx2 = -1, val = -1; if (abs(x - idx) >= N / 2) idx2 = x, val = P[x]; else { if (idx < N / 2) ...
partial
1
15
[{"idx": 0, "reason": "wrong_answer", "expected": "1\n1 2", "got": "1\n2 1"}, {"idx": 1, "reason": "wrong_answer", "expected": "2\n1 3\n2 4", "got": "2\n4 2\n1 3"}, {"idx": 2, "reason": "wrong_answer", "expected": "5\n1 6\n2 6\n1 6\n1 5\n1 4", "got": "3\n5 1\n1 4\n5 2"}, {"idx": 3, "reason": "wrong_answer", "expected":...
codeforces
C
419
1148_C. Crazy Diamond
You are given a permutation p of integers from 1 to n, where n is an even number. Your goal is to sort the permutation. To do so, you can perform zero or more operations of the following type: * take two indices i and j such that 2 ⋅ |i - j| ≥ n and swap p_i and p_j. There is no need to minimize the number of...
java
import java.io.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.*; import static java.lang.Math.*; public class Main { public static void main(String[] args) { new Thread(null, null, "Rahsut", 1 << 25) { public void run() { try { ...
partial
4
15
[{"idx": 2, "reason": "wrong_answer", "expected": "5\n1 6\n2 6\n1 6\n1 5\n1 4", "got": "9\n1 4\n6 2\n6 1\n4 1\n6 1\n6 2\n4 1\n5 1\n4 1"}, {"idx": 3, "reason": "wrong_answer", "expected": "17\n3 10\n10 2\n5 10\n10 3\n7 1\n1 10\n10 4\n6 1\n1 10\n10 5\n7 1\n1 6\n9 1\n1 7\n9 1\n1 8\n1 10", "got": "25\n1 10\n2 10\n1 10\n2 1...
codeforces
C
419
1148_C. Crazy Diamond
You are given a permutation p of integers from 1 to n, where n is an even number. Your goal is to sort the permutation. To do so, you can perform zero or more operations of the following type: * take two indices i and j such that 2 ⋅ |i - j| ≥ n and swap p_i and p_j. There is no need to minimize the number of...
python3
n = int(input()) p = [*map(int, input().split())] p = [i - 1 for i in p] #print(p) pos = {} ans = [] for i, j in enumerate(p): pos[j] = i def swap(i, j): ans.append((i + 1, j + 1)) pos[p[i]], pos[p[j]] = pos[p[j]], pos[p[i]] p[i], p[j] = p[j], p[i] def do(i): j=pos[i] if j<n//2: ...
partial
8
15
[{"idx": 1, "reason": "wrong_answer", "expected": "2\n1 3\n2 4", "got": "6\n4 1\n1 4\n4 2\n1 4\n4 1\n1 3"}, {"idx": 2, "reason": "wrong_answer", "expected": "5\n1 6\n2 6\n1 6\n1 5\n1 4", "got": "7\n1 6\n6 2\n5 1\n1 4\n6 1\n1 5\n1 6"}, {"idx": 5, "reason": "wrong_answer", "expected": "5\n1 6\n2 6\n1 6\n1 5\n1 4", "got":...
codeforces
C
419
1148_C. Crazy Diamond
You are given a permutation p of integers from 1 to n, where n is an even number. Your goal is to sort the permutation. To do so, you can perform zero or more operations of the following type: * take two indices i and j such that 2 ⋅ |i - j| ≥ n and swap p_i and p_j. There is no need to minimize the number of...
java
import java.io.*; import java.util.*; import java.util.stream.*; public class ProblemC { private static boolean debug = false; private static int N; private static int[] A; private static void solveProblem(InputStream instr) throws Exception { InputReader sc = new InputReader(instr); ...
partial
4
15
[{"idx": 2, "reason": "wrong_answer", "expected": "5\n1 6\n2 6\n1 6\n1 5\n1 4", "got": "5\n1 4\n1 4\n1 5\n1 4\n2 5"}, {"idx": 3, "reason": "wrong_answer", "expected": "17\n3 10\n10 2\n5 10\n10 3\n7 1\n1 10\n10 4\n6 1\n1 10\n10 5\n7 1\n1 6\n9 1\n1 7\n9 1\n1 8\n1 10", "got": "23\n2 7\n1 7\n3 8\n2 8\n5 10\n3 10\n3 8\n3 9\...
codeforces
C
419
1148_C. Crazy Diamond
You are given a permutation p of integers from 1 to n, where n is an even number. Your goal is to sort the permutation. To do so, you can perform zero or more operations of the following type: * take two indices i and j such that 2 ⋅ |i - j| ≥ n and swap p_i and p_j. There is no need to minimize the number of...
cpp
#include <bits/stdc++.h> using namespace std; const long long N = 4e5 + 30, Mod = 1e9 + 7; const long long SQ = 330; long long g[N], a[N], n; vector<pair<long long, long long> > ans; void _swap(long long i, long long j) { g[a[i]] = j; g[a[j]] = i; swap(a[i], a[j]); ans.push_back({i, j}); } void change(long long...
partial
4
15
[{"idx": 2, "reason": "wrong_answer", "expected": "5\n1 6\n2 6\n1 6\n1 5\n1 4", "got": "9\n1 4\n4 1\n1 6\n2 6\n1 6\n1 4\n5 1\n4 1\n5 1"}, {"idx": 3, "reason": "wrong_answer", "expected": "17\n3 10\n10 2\n5 10\n10 3\n7 1\n1 10\n10 4\n6 1\n1 10\n10 5\n7 1\n1 6\n9 1\n1 7\n9 1\n1 8\n1 10", "got": "25\n2 10\n1 10\n2 10\n3 1...
codeforces
C
419
1148_C. Crazy Diamond
You are given a permutation p of integers from 1 to n, where n is an even number. Your goal is to sort the permutation. To do so, you can perform zero or more operations of the following type: * take two indices i and j such that 2 ⋅ |i - j| ≥ n and swap p_i and p_j. There is no need to minimize the number of...
python2
def main(): inp = readnumbers() ii = 0 n = inp[ii] ii += 1 P = [p-1 for p in inp[ii:ii+n]] ii += n where = [0]*n for i in range(n): where[P[i]] = i Z = [] def swapper(ind1,ind2): if ind1>ind2: ind1,ind2 = ind2,ind1 swaps = [] ...
partial
2
15
[{"idx": 1, "reason": "wrong_answer", "expected": "2\n1 3\n2 4", "got": "10\n4 1\n2 4\n4 1\n2 4\n4 1\n1 4\n3 1\n4 1\n3 1\n1 4"}, {"idx": 2, "reason": "wrong_answer", "expected": "5\n1 6\n2 6\n1 6\n1 5\n1 4", "got": "13\n5 1\n2 6\n6 1\n2 6\n5 1\n4 1\n2 6\n6 1\n2 6\n4 1\n1 6\n6 2\n1 6"}, {"idx": 3, "reason": "wrong_answe...
codeforces
C
419
1148_C. Crazy Diamond
You are given a permutation p of integers from 1 to n, where n is an even number. Your goal is to sort the permutation. To do so, you can perform zero or more operations of the following type: * take two indices i and j such that 2 ⋅ |i - j| ≥ n and swap p_i and p_j. There is no need to minimize the number of...
python3
n = int(input())//2 array = [int(i) for i in input().split()] pos = [0]* (2*n+1) for i in range(2*n): pos[array[i]] = i printl = [] #print(pos) def swap(a, b): #print(a, b) printl.append(str(a+1) + ' ' + str(b+1)) temp = array[a] array[a] = array[b] array[b] = temp pos[array[b]] = b pos...
partial
1
15
[{"idx": 0, "reason": "wrong_answer", "expected": "1\n1 2", "got": "1\n2 1"}, {"idx": 1, "reason": "wrong_answer", "expected": "2\n1 3\n2 4", "got": "2\n3 1\n4 2"}, {"idx": 2, "reason": "wrong_answer", "expected": "5\n1 6\n2 6\n1 6\n1 5\n1 4", "got": "9\n4 1\n1 4\n1 6\n6 2\n1 5\n1 4\n1 6\n1 5\n1 6"}, {"idx": 3, "reason...
codeforces
C
419
1148_C. Crazy Diamond
You are given a permutation p of integers from 1 to n, where n is an even number. Your goal is to sort the permutation. To do so, you can perform zero or more operations of the following type: * take two indices i and j such that 2 ⋅ |i - j| ≥ n and swap p_i and p_j. There is no need to minimize the number of...
python3
import sys,math def read_int(): return int(sys.stdin.readline().strip()) def read_int_list(): return list(map(int,sys.stdin.readline().strip().split())) def read_string(): return sys.stdin.readline().strip() def read_string_list(delim=" "): return sys.stdin.readline().strip().split(delim) ###### Author : Sami...
partial
4
15
[{"idx": 2, "reason": "wrong_answer", "expected": "5\n1 6\n2 6\n1 6\n1 5\n1 4", "got": "9\n1 4\n2 6\n4 1\n1 6\n1 4\n6 2\n5 1\n4 1\n1 5"}, {"idx": 3, "reason": "wrong_answer", "expected": "17\n3 10\n10 2\n5 10\n10 3\n7 1\n1 10\n10 4\n6 1\n1 10\n10 5\n7 1\n1 6\n9 1\n1 7\n9 1\n1 8\n1 10", "got": "25\n2 10\n1 10\n10 2\n3 1...
codeforces
C
419
1148_C. Crazy Diamond
You are given a permutation p of integers from 1 to n, where n is an even number. Your goal is to sort the permutation. To do so, you can perform zero or more operations of the following type: * take two indices i and j such that 2 ⋅ |i - j| ≥ n and swap p_i and p_j. There is no need to minimize the number of...
python2
N = input() p = map(int,raw_input().split()) pos = {p[i]:i for i in range(N)} res = [] for i in range(N) : if p[i] == i+1 : continue curVal = p[i] nxt = pos[i+1] if abs(2*(i-nxt)) >= N : res.append((i+1,nxt+1)) elif nxt >= N/2 and i < N/2 : res.append((1,nxt+1)) res.append((i+1,N)) res.ap...
partial
4
15
[{"idx": 2, "reason": "wrong_answer", "expected": "5\n1 6\n2 6\n1 6\n1 5\n1 4", "got": "9\n1 4\n1 4\n2 6\n1 6\n1 4\n2 6\n1 5\n1 4\n1 5"}, {"idx": 3, "reason": "wrong_answer", "expected": "17\n3 10\n10 2\n5 10\n10 3\n7 1\n1 10\n10 4\n6 1\n1 10\n10 5\n7 1\n1 6\n9 1\n1 7\n9 1\n1 8\n1 10", "got": "25\n2 10\n1 10\n2 10\n3 1...
codeforces
C
419
1148_C. Crazy Diamond
You are given a permutation p of integers from 1 to n, where n is an even number. Your goal is to sort the permutation. To do so, you can perform zero or more operations of the following type: * take two indices i and j such that 2 ⋅ |i - j| ≥ n and swap p_i and p_j. There is no need to minimize the number of...
python2
import fileinput def D(a):print(a) def S(s,I):return int(s.split(" ")[I]) def sr(I,J): global R t=R[I] R[I]=R[J] R[J]=t def sa(I,J): global A global R global s global P s[P]=str(I+1)+" "+str(J+1); P+=1 sr(A[I],A[J]) t=A[I] A[I]=A[J] A[J]=t def swA(a,b,c,d): gl...
partial
4
15
[{"idx": 2, "reason": "wrong_answer", "expected": "5\n1 6\n2 6\n1 6\n1 5\n1 4", "got": "9\n1 4\n1 4\n1 6\n2 6\n1 6\n1 4\n5 1\n4 1\n5 1"}, {"idx": 3, "reason": "wrong_answer", "expected": "17\n3 10\n10 2\n5 10\n10 3\n7 1\n1 10\n10 4\n6 1\n1 10\n10 5\n7 1\n1 6\n9 1\n1 7\n9 1\n1 8\n1 10", "got": "25\n1 10\n2 10\n1 10\n2 1...
codeforces
C
421
1187_G. Gang Up
The leader of some very secretive organization has decided to invite all other members to a meeting. All members of the organization live in the same town which can be represented as n crossroads connected by m two-directional streets. The meeting will be held in the leader's house near the crossroad 1. There are k mem...
java
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.InputMismatchException; import java.util.List; public class G { InputStream is; PrintWriter out; String INPUT = ""; void ...
all_fail
0
25
[{"idx": 0, "reason": "runtime_error", "rc": 1, "stderr": "Exception in thread \"main\" java.util.InputMismatchException\n\tat G.readByte(G.java:225)\n\tat G.ni(G.java:280)\n\tat G.solve(G.java:17)\n\tat G.run(G.java:213)\n\tat G.main(G.java:218)\n", "stdout_tail": ""}, {"idx": 1, "reason": "runtime_error", "rc": 1, "s...
codeforces
G
422
1206_F. Almost All
You are given a tree with n nodes. You have to write non-negative integers on its edges so that the following condition would be satisfied: For every two nodes i, j, look at the path between them and count the sum of numbers on the edges of this path. Write all obtained sums on the blackboard. Then every integer from ...
cpp
#include <bits/stdc++.h> using namespace std; const int N = 1010; struct Edge { int to, next; } e[N * 2]; int lst[N], d; void add(int x, int y) { e[d].to = y, e[d].next = lst[x], lst[x] = d++; } int fa[N], n, sz[N]; int read() { int w = 0, f = 0; char c = getchar(); while ((c < '0' || c > '9') && c != '-') c = ...
partial
1
15
[{"idx": 0, "reason": "wrong_answer", "expected": "2 4 1\n2 3 2\n2 1 4", "got": "1 2 1\n2 3 1\n2 4 2"}, {"idx": 1, "reason": "wrong_answer", "expected": "2 3 1\n2 1 2", "got": "1 2 1\n2 3 1"}, {"idx": 2, "reason": "wrong_answer", "expected": "1 2 1\n2 5 1\n1 3 3\n1 4 6", "got": "1 3 1\n1 4 2\n1 2 3\n2 5 3"}, {"idx": 3,...
codeforces
F
422
1206_F. Almost All
You are given a tree with n nodes. You have to write non-negative integers on its edges so that the following condition would be satisfied: For every two nodes i, j, look at the path between them and count the sum of numbers on the edges of this path. Write all obtained sums on the blackboard. Then every integer from ...
cpp
#include <bits/stdc++.h> using namespace std; int N, x, y; vector<vector<int>> asd; vector<int> subtree_size; int find_centroid(int root, vector<vector<int>> edge, function<void(vector<int>)> callback) { vector<int> subtree(edge.size() + 1); function<void(int, int)> get_size = [&](int node, int pa...
partial
1
15
[{"idx": 0, "reason": "wrong_answer", "expected": "2 4 1\n2 3 2\n2 1 4", "got": "2 3 1\n\n2 4 2\n2 1 4"}, {"idx": 1, "reason": "wrong_answer", "expected": "2 3 1\n2 1 2", "got": "2 1 1\n\n2 3 2"}, {"idx": 2, "reason": "wrong_answer", "expected": "1 2 1\n2 5 1\n1 3 3\n1 4 6", "got": "1 3 1\n1 4 2\n\n1 2 3\n2 5 3"}, {"id...
codeforces
F
422
1206_F. Almost All
You are given a tree with n nodes. You have to write non-negative integers on its edges so that the following condition would be satisfied: For every two nodes i, j, look at the path between them and count the sum of numbers on the edges of this path. Write all obtained sums on the blackboard. Then every integer from ...
cpp
#include <bits/stdc++.h> using namespace std; vector<vector<int>> e; int root(vector<int> &p, vector<int> &s, int r) { if (e[r].size() == 1 and p[r] != -1) return s[r] = 1; else { s[r] = 0; for (int c : e[r]) { if (p[r] != c) { p[c] = r; s[r] += root(p, s, c); } } ret...
partial
3
15
[{"idx": 0, "reason": "wrong_answer", "expected": "2 4 1\n2 3 2\n2 1 4", "got": "1 2 1\n2 4 1\n2 3 2"}, {"idx": 1, "reason": "wrong_answer", "expected": "2 3 1\n2 1 2", "got": "1 2 1\n2 3 1"}, {"idx": 3, "reason": "wrong_answer", "expected": "33 39 1\n39 40 1\n40 1 1\n40 3 2\n39 34 4\n34 28 1\n34 5 2\n5 36 1\n39 26 8\n...
codeforces
F
422
1206_F. Almost All
You are given a tree with n nodes. You have to write non-negative integers on its edges so that the following condition would be satisfied: For every two nodes i, j, look at the path between them and count the sum of numbers on the edges of this path. Write all obtained sums on the blackboard. Then every integer from ...
python3
import math n = int(input()) if n == 1: print() else: edge = [list(map(int, input().split())) for i in range(1, n) ] g = {} for x, y in edge: if x not in g: g[x] = [] if y not in g: g[y] = [] g[x].append(y) g[y].append(x) ...
partial
9
15
[{"idx": 2, "reason": "wrong_answer", "expected": "1 2 1\n2 5 1\n1 3 3\n1 4 6", "got": "1 3 1\n1 4 2\n1 2 3\n2 5 3"}, {"idx": 4, "reason": "wrong_answer", "expected": "2 1 1\n10 2 1\n8 10 1\n4 1 4\n6 4 4\n3 6 4\n9 1 16\n5 9 4\n7 9 8", "got": "1 2 1\n2 10 1\n10 8 1\n1 4 4\n4 6 4\n6 3 4\n1 9 16\n9 5 4\n9 7 8"}, {"idx": 5...
codeforces
F
424
1249_D1. Too Many Segments (easy version)
The only difference between easy and hard versions is constraints. You are given n segments on the coordinate axis OX. Segments can intersect, lie inside each other and even coincide. The i-th segment is [l_i; r_i] (l_i ≤ r_i) and it covers all integer points j such that l_i ≤ j ≤ r_i. The integer point is called bad...
java
import java.util.*; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; public class r558p4{ private static InputReader sc; private static PrintWriter pw; static class InputReader { private final InputStream stream; private final byte[] buf = new byte[8192]...
partial
1
7
[{"idx": 0, "reason": "wrong_answer", "expected": "3\n4 1 5", "got": "3\n1 2 4"}, {"idx": 1, "reason": "wrong_answer", "expected": "3\n7 4 6", "got": "3\n1 4 7"}, {"idx": 3, "reason": "wrong_answer", "expected": "8\n5 7 8 10 11 12 3 2", "got": "8\n2 3 5 7 8 10 11 12"}, {"idx": 4, "reason": "wrong_answer", "expected": "...
codeforces
D
424
1249_D1. Too Many Segments (easy version)
The only difference between easy and hard versions is constraints. You are given n segments on the coordinate axis OX. Segments can intersect, lie inside each other and even coincide. The i-th segment is [l_i; r_i] (l_i ≤ r_i) and it covers all integer points j such that l_i ≤ j ≤ r_i. The integer point is called bad...
cpp
#include <bits/stdc++.h> using namespace std; int arr[200005], tree[4 * 200005], lazy[4 * 200005]; struct info { int l, r, i; }; vector<info> vec; bool comp(info a, info b) { if (a.r != b.r) return a.r < b.r; return a.l < b.l; } void update(int node, int a, int b, int i, int j, int value) { if (lazy[node] != 0)...
partial
2
7
[{"idx": 1, "reason": "wrong_answer", "expected": "3\n7 4 6", "got": "3\n7 4 1"}, {"idx": 3, "reason": "wrong_answer", "expected": "8\n5 7 8 10 11 12 3 2", "got": "8\n8 7 5 11 12 10 2 3"}, {"idx": 4, "reason": "wrong_answer", "expected": "6\n11 8 9 7 6 12", "got": "6\n8 6 9 7 11 12"}, {"idx": 5, "reason": "wrong_answer...
codeforces
D
424
1249_D1. Too Many Segments (easy version)
The only difference between easy and hard versions is constraints. You are given n segments on the coordinate axis OX. Segments can intersect, lie inside each other and even coincide. The i-th segment is [l_i; r_i] (l_i ≤ r_i) and it covers all integer points j such that l_i ≤ j ≤ r_i. The integer point is called bad...
java
import java.io.*; import java.nio.CharBuffer; import java.util.*; public class P1249D_2 { private static final int MAX = 200_000; public static void main(String[] args) { SimpleScanner scanner = new SimpleScanner(System.in); PrintWriter writer = new PrintWriter(System.out); int n = s...
partial
2
7
[{"idx": 0, "reason": "wrong_answer", "expected": "3\n4 1 5", "got": "3\n4 1 2"}, {"idx": 1, "reason": "wrong_answer", "expected": "3\n7 4 6", "got": "3\n7 4 2"}, {"idx": 3, "reason": "wrong_answer", "expected": "8\n5 7 8 10 11 12 3 2", "got": "8\n5 7 8 10 11 12 2 3"}, {"idx": 4, "reason": "wrong_answer", "expected": "...
codeforces
D
424
1249_D1. Too Many Segments (easy version)
The only difference between easy and hard versions is constraints. You are given n segments on the coordinate axis OX. Segments can intersect, lie inside each other and even coincide. The i-th segment is [l_i; r_i] (l_i ≤ r_i) and it covers all integer points j such that l_i ≤ j ≤ r_i. The integer point is called bad...
python3
import sys from heapq import * #sys.stdin = open('in', 'r') #n = int(input()) n,k = map(int, input().split()) seg = [] for i in range(n): l, r = map(int, input().split()) seg.append((l, r, i+1)) seg.sort() c = 0 res = [] i = 0 hmin = [] hmax = [] rem = set() while i < n: l,r,si = seg[i] while i < n and ...
partial
2
7
[{"idx": 0, "reason": "wrong_answer", "expected": "3\n4 1 5", "got": "3\n1 4 2"}, {"idx": 1, "reason": "wrong_answer", "expected": "3\n7 4 6", "got": "3\n7 4 1"}, {"idx": 3, "reason": "wrong_answer", "expected": "8\n5 7 8 10 11 12 3 2", "got": "8\n5 7 8 10 11 12 2 3"}, {"idx": 4, "reason": "wrong_answer", "expected": "...
codeforces
D
424
1249_D1. Too Many Segments (easy version)
The only difference between easy and hard versions is constraints. You are given n segments on the coordinate axis OX. Segments can intersect, lie inside each other and even coincide. The i-th segment is [l_i; r_i] (l_i ≤ r_i) and it covers all integer points j such that l_i ≤ j ≤ r_i. The integer point is called bad...
cpp
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 100; int n, k; vector<pair<int, int> > a[MAXN]; int main(void) { ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); cin >> n >> k; for (int i = 1; i <= n; i++) { int l, r; cin >> l >> r; a[l].push_ba...
partial
1
7
[{"idx": 0, "reason": "wrong_answer", "expected": "3\n4 1 5", "got": "3\n1 4 5"}, {"idx": 1, "reason": "wrong_answer", "expected": "3\n7 4 6", "got": "3\n4 6 7"}, {"idx": 3, "reason": "wrong_answer", "expected": "8\n5 7 8 10 11 12 3 2", "got": "8\n2 3 5 7 8 10 11 12"}, {"idx": 4, "reason": "wrong_answer", "expected": "...
codeforces
D
424
1249_D1. Too Many Segments (easy version)
The only difference between easy and hard versions is constraints. You are given n segments on the coordinate axis OX. Segments can intersect, lie inside each other and even coincide. The i-th segment is [l_i; r_i] (l_i ≤ r_i) and it covers all integer points j such that l_i ≤ j ≤ r_i. The integer point is called bad...
cpp
#include <bits/stdc++.h> using namespace std; const int MAX = 200009; int n, k; int x, y; int tree[4 * MAX], lazy[4 * MAX]; vector<pair<pair<int, int>, int> > v; vector<int> ans; void update(int low, int high, int pos) { if (lazy[pos] != 0) { tree[pos] += lazy[pos]; if (low != high) { lazy[2 * pos] += l...
partial
2
7
[{"idx": 1, "reason": "wrong_answer", "expected": "3\n7 4 6", "got": "3\n7 4 1"}, {"idx": 3, "reason": "wrong_answer", "expected": "8\n5 7 8 10 11 12 3 2", "got": "8\n8 7 5 11 12 10 2 3"}, {"idx": 4, "reason": "wrong_answer", "expected": "6\n11 8 9 7 6 12", "got": "6\n8 6 9 7 11 12"}, {"idx": 5, "reason": "wrong_answer...
codeforces
D
424
1249_D1. Too Many Segments (easy version)
The only difference between easy and hard versions is constraints. You are given n segments on the coordinate axis OX. Segments can intersect, lie inside each other and even coincide. The i-th segment is [l_i; r_i] (l_i ≤ r_i) and it covers all integer points j such that l_i ≤ j ≤ r_i. The integer point is called bad...
python3
class BIT: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.size: self.tree[i] += x ...
partial
1
7
[{"idx": 0, "reason": "wrong_answer", "expected": "3\n4 1 5", "got": "3\n1 4 5"}, {"idx": 1, "reason": "wrong_answer", "expected": "3\n7 4 6", "got": "3\n4 7 6"}, {"idx": 3, "reason": "wrong_answer", "expected": "8\n5 7 8 10 11 12 3 2", "got": "8\n8 7 5 11 12 10 2 3"}, {"idx": 4, "reason": "wrong_answer", "expected": "...
codeforces
D
424
1249_D1. Too Many Segments (easy version)
The only difference between easy and hard versions is constraints. You are given n segments on the coordinate axis OX. Segments can intersect, lie inside each other and even coincide. The i-th segment is [l_i; r_i] (l_i ≤ r_i) and it covers all integer points j such that l_i ≤ j ≤ r_i. The integer point is called bad...
python3
import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.wri...
partial
2
7
[{"idx": 0, "reason": "wrong_answer", "expected": "3\n4 1 5", "got": "3\n1 4 2"}, {"idx": 1, "reason": "wrong_answer", "expected": "3\n7 4 6", "got": "3\n7 4 1"}, {"idx": 3, "reason": "wrong_answer", "expected": "8\n5 7 8 10 11 12 3 2", "got": "8\n5 7 8 10 11 12 2 3"}, {"idx": 4, "reason": "wrong_answer", "expected": "...
codeforces
D
424
1249_D1. Too Many Segments (easy version)
The only difference between easy and hard versions is constraints. You are given n segments on the coordinate axis OX. Segments can intersect, lie inside each other and even coincide. The i-th segment is [l_i; r_i] (l_i ≤ r_i) and it covers all integer points j such that l_i ≤ j ≤ r_i. The integer point is called bad...
java
import java.io.*; import java.util.*; public class seg { public static void main(String s[]) throws Exception { int len =(int)1e5; len*=2; Reader r = new Reader(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = r.nextInt(); int k=r....
partial
2
7
[{"idx": 0, "reason": "wrong_answer", "expected": "3\n4 1 5", "got": "3\n1 4 2"}, {"idx": 1, "reason": "wrong_answer", "expected": "3\n7 4 6", "got": "3\n7 4 1"}, {"idx": 3, "reason": "wrong_answer", "expected": "8\n5 7 8 10 11 12 3 2", "got": "8\n5 7 8 10 11 12 2 3"}, {"idx": 4, "reason": "wrong_answer", "expected": "...
codeforces
D
424
1249_D1. Too Many Segments (easy version)
The only difference between easy and hard versions is constraints. You are given n segments on the coordinate axis OX. Segments can intersect, lie inside each other and even coincide. The i-th segment is [l_i; r_i] (l_i ≤ r_i) and it covers all integer points j such that l_i ≤ j ≤ r_i. The integer point is called bad...
python2
from sys import stdin import heapq raw_input = lambda: stdin.readline().rstrip() input = lambda: int(raw_input()) I=lambda: map(int, raw_input().split()) n,k = I() lst = [] for i in xrange(n): l,r = I() lst.append((l, 0, i+1, r+1)) lst.append((r+1, 1, i+1)) lst.sort(key=lambda x: x[0]) q = [] lLst = len(lst) c = 0 j...
partial
2
7
[{"idx": 0, "reason": "wrong_answer", "expected": "3\n4 1 5", "got": "3\n1 4 2"}, {"idx": 1, "reason": "wrong_answer", "expected": "3\n7 4 6", "got": "3\n7 4 1"}, {"idx": 3, "reason": "wrong_answer", "expected": "8\n5 7 8 10 11 12 3 2", "got": "8\n5 7 8 10 11 12 2 3"}, {"idx": 4, "reason": "wrong_answer", "expected": "...
codeforces
D
424
1249_D1. Too Many Segments (easy version)
The only difference between easy and hard versions is constraints. You are given n segments on the coordinate axis OX. Segments can intersect, lie inside each other and even coincide. The i-th segment is [l_i; r_i] (l_i ≤ r_i) and it covers all integer points j such that l_i ≤ j ≤ r_i. The integer point is called bad...
python2
# <editor-fold desc="Fast IO"> # !/usr/bin/env python from __future__ import division, print_function import os import sys from io import BytesIO, IOBase if sys.version_info[0] < 3: from __builtin__ import xrange as range from future_builtins import ascii, filter, hex, map, oct, zip BUFFER_SIZE = 8192 clas...
partial
1
7
[{"idx": 0, "reason": "wrong_answer", "expected": "3\n4 1 5", "got": "3\n1 2 4"}, {"idx": 1, "reason": "wrong_answer", "expected": "3\n7 4 6", "got": "3\n1 4 7"}, {"idx": 3, "reason": "wrong_answer", "expected": "8\n5 7 8 10 11 12 3 2", "got": "8\n2 3 5 7 8 10 11 12"}, {"idx": 4, "reason": "wrong_answer", "expected": "...
codeforces
D
424
1249_D1. Too Many Segments (easy version)
The only difference between easy and hard versions is constraints. You are given n segments on the coordinate axis OX. Segments can intersect, lie inside each other and even coincide. The i-th segment is [l_i; r_i] (l_i ≤ r_i) and it covers all integer points j such that l_i ≤ j ≤ r_i. The integer point is called bad...
python2
from sys import stdin from heapq import * rints = lambda: [int(x) for x in stdin.readline().split()] Max = 2 * 10 ** 5 + 2 n, m = rints() a, ans = sorted([rints() + [i] for i in range(1, n + 1)], key=lambda x: (x[0], -x[1]))[::-1], [] plus, minus = [0] * Max, [0] * Max for i in range(n): plus[a[i][0]] += 1 p...
partial
2
7
[{"idx": 0, "reason": "wrong_answer", "expected": "3\n4 1 5", "got": "3\n1 4 2"}, {"idx": 1, "reason": "wrong_answer", "expected": "3\n7 4 6", "got": "3\n7 4 1"}, {"idx": 3, "reason": "wrong_answer", "expected": "8\n5 7 8 10 11 12 3 2", "got": "8\n5 7 8 10 11 12 2 3"}, {"idx": 4, "reason": "wrong_answer", "expected": "...
codeforces
D
425
1267_L. Lexicography
Lucy likes letters. She studied the definition of the lexicographical order at school and plays with it. At first, she tried to construct the lexicographically smallest word out of given letters. It was so easy! Then she tried to build multiple words and minimize one of them. This was much harder! Formally, Lucy want...
python3
# ------------------- fast io -------------------- import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode...
partial
22
25
[{"idx": 3, "reason": "wrong_answer", "expected": "aabbbffff\naabbcddde\nggghhhhhh\nhiiijjjjj\nkkkklllmm\nnnnnnnnoo\nooppqqqqq\nrrrrrssst\ntttttvvww\nwxyyyyyyz", "got": "aabbbfhjl\naabbcddde\nfhjlnqrtx\nfhjmnqrty\nfhjmoqsty\nghknoqsvy\ngiknoqsvy\ngiknortwy\nhiknprtwy\nhjlnprtwz"}, {"idx": 8, "reason": "wrong_answer", "...
codeforces
UNKNOWN
425
1267_L. Lexicography
Lucy likes letters. She studied the definition of the lexicographical order at school and plays with it. At first, she tried to construct the lexicographically smallest word out of given letters. It was so easy! Then she tried to build multiple words and minimize one of them. This was much harder! Formally, Lucy want...
java
import java.io.File; import java.io.FileNotFoundException; import java.util.Arrays; import java.util.PriorityQueue; import java.util.Scanner; public class Lexicography { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String[] nlk = scan.nextLine().split(" "); int n = Integer.pa...
partial
20
25
[{"idx": 1, "reason": "wrong_answer", "expected": "ad\nbc\nef", "got": "ae\nbc\ndf"}, {"idx": 3, "reason": "wrong_answer", "expected": "aabbbffff\naabbcddde\nggghhhhhh\nhiiijjjjj\nkkkklllmm\nnnnnnnnoo\nooppqqqqq\nrrrrrssst\ntttttvvww\nwxyyyyyyz", "got": "aabbbhjln\naabbcddde\nfhjlnqrtx\nfhjlnqrty\nfhjmoqsty\nfhjmoqsvy\...
codeforces
UNKNOWN
425
1267_L. Lexicography
Lucy likes letters. She studied the definition of the lexicographical order at school and plays with it. At first, she tried to construct the lexicographically smallest word out of given letters. It was so easy! Then she tried to build multiple words and minimize one of them. This was much harder! Formally, Lucy want...
python3
n , l , k = map(int,input().split(' ')) s = list(input()) s.sort() i = 0 ans = [[] for _ in range(n)] fill = [i for i in range(k)] while len(ans[k-1]) < l : temp = [] for element in fill : ans[element].append(s[i]) i+=1 for element in fill : if ans[k-1][-1] == ans[element][-1] ...
partial
22
25
[{"idx": 3, "reason": "wrong_answer", "expected": "aabbbffff\naabbcddde\nggghhhhhh\nhiiijjjjj\nkkkklllmm\nnnnnnnnoo\nooppqqqqq\nrrrrrssst\ntttttvvww\nwxyyyyyyz", "got": "aabbbfhjl\naabbcddde\nfhjlnqrtx\nfhjmnqrty\nfhjmoqsty\nghknoqsvy\ngiknoqsvy\ngiknortwy\nhiknprtwy\nhjlnprtwz"}, {"idx": 8, "reason": "wrong_answer", "...
codeforces
UNKNOWN
427
1332_G. No Monotone Triples
Given a sequence of integers a of length n, a tuple (i,j,k) is called monotone triples if * 1 ≤ i<j<k≤ n; * a_i ≤ a_j ≤ a_k or a_i ≥ a_j ≥ a_k is satisfied. For example, a=[5,3,4,5], then (2,3,4) is monotone triples for sequence a while (1,3,4) is not. Bob is given a sequence of integers a of length n in a ...
cpp
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5; int a[maxn + 11], lmin[maxn + 11], lmax[maxn + 11], rmin[maxn + 11], rmax[maxn + 11]; int ans3[maxn + 11][5], ans4[maxn + 11][5]; set<int>::iterator it; vector<int> v[maxn + 11]; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);...
partial
2
6
[{"idx": 1, "reason": "wrong_answer", "expected": "4\n3 4 6 7\n3\n4 6 7\n4\n3 4 6 7\n3\n2 4 5\n3\n5 6 7", "got": "4\n3 4 6 7\n3\n6 7 8\n4\n3 4 6 7\n3\n3 4 5\n3\n6 7 8"}, {"idx": 3, "reason": "wrong_answer", "expected": "4\n14 15 16 17\n4\n17 18 19 20\n3\n4 5 6\n3\n3 4 5\n4\n10 11 12 13\n4\n23 24 25 26\n0\n\n3\n19 21 22...
codeforces
G
427
1332_G. No Monotone Triples
Given a sequence of integers a of length n, a tuple (i,j,k) is called monotone triples if * 1 ≤ i<j<k≤ n; * a_i ≤ a_j ≤ a_k or a_i ≥ a_j ≥ a_k is satisfied. For example, a=[5,3,4,5], then (2,3,4) is monotone triples for sequence a while (1,3,4) is not. Bob is given a sequence of integers a of length n in a ...
cpp
#include <bits/stdc++.h> using namespace std; const int N = 200005; int a[N], n, Q; int ri3[N], ri4[N]; vector<int> ans3[N], ans4[N]; void init_ans_3() { static int q[N]; static int le[N], ri[N]; a[0] = a[n + 1] = -(1 << 30); int t = 0; q[++t] = 0; for (int i = (int)(1); i <= (int)(n); i++) { for (; a[q...
partial
3
6
[{"idx": 1, "reason": "wrong_answer", "expected": "4\n3 4 6 7\n3\n4 6 7\n4\n3 4 6 7\n3\n2 4 5\n3\n5 6 7", "got": "4\n3 4 6 7\n3\n5 6 7\n4\n3 4 6 7\n3\n2 3 5\n3\n5 6 7"}, {"idx": 3, "reason": "wrong_answer", "expected": "4\n14 15 16 17\n4\n17 18 19 20\n3\n4 5 6\n3\n3 4 5\n4\n10 11 12 13\n4\n23 24 25 26\n0\n\n3\n19 21 22...
codeforces
G
427
1332_G. No Monotone Triples
Given a sequence of integers a of length n, a tuple (i,j,k) is called monotone triples if * 1 ≤ i<j<k≤ n; * a_i ≤ a_j ≤ a_k or a_i ≥ a_j ≥ a_k is satisfied. For example, a=[5,3,4,5], then (2,3,4) is monotone triples for sequence a while (1,3,4) is not. Bob is given a sequence of integers a of length n in a ...
cpp
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; pair<int, int> Min[20][N], Max[20][N]; int lg[N]; int n, a[N], m; int lft[N], rgt[N]; int lft2[N]; int stk[N], top; inline pair<int, int> qmx(int l, int r) { int g = lg[r - l + 1]; return max(Max[g][l], Max[g][r - (1 << g) + 1]); } inline pair<int...
partial
2
6
[{"idx": 1, "reason": "wrong_answer", "expected": "4\n3 4 6 7\n3\n4 6 7\n4\n3 4 6 7\n3\n2 4 5\n3\n5 6 7", "got": "4\n3 4 6 7\n3\n6 7 8\n4\n3 4 6 7\n3\n3 4 5\n3\n6 7 8"}, {"idx": 3, "reason": "wrong_answer", "expected": "4\n14 15 16 17\n4\n17 18 19 20\n3\n4 5 6\n3\n3 4 5\n4\n10 11 12 13\n4\n23 24 25 26\n0\n\n3\n19 21 22...
codeforces
G
427
1332_G. No Monotone Triples
Given a sequence of integers a of length n, a tuple (i,j,k) is called monotone triples if * 1 ≤ i<j<k≤ n; * a_i ≤ a_j ≤ a_k or a_i ≥ a_j ≥ a_k is satisfied. For example, a=[5,3,4,5], then (2,3,4) is monotone triples for sequence a while (1,3,4) is not. Bob is given a sequence of integers a of length n in a ...
python3
import sys import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline from operator import itemgetter import bisect n,q=map(int,input().split()) A=[-1]+list(map(int,input().split())) Q=[list(map(int,input().split()))+[i] for i in range(q)] Q.sort(key=itemgetter(1)) Q_ind=0 ANS1=[-1000,-1000,-1000,-100...
all_fail
0
6
[{"idx": 0, "reason": "runtime_error", "rc": 1, "stderr": "Traceback (most recent call last):\n File \"/tmp/sbx_424dkyr7/tmpy92vryk2.py\", line 7, in <module>\n n,q=map(int,input().split())\n ^^^\nValueError: not enough values to unpack (expected 2, got 0)\n", "stdout_tail": ""}, {"idx": 1, "reason": "runtime_er...
codeforces
G
430
141_C. Queue
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him. After a while the cashier has a lunch break and t...
java
import java.io.*; import java.util.*; public class Ochered implements Runnable { public static void main(String[] args) { new Thread(new Ochered()).run(); } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer in; PrintWriter...
partial
3
14
[{"idx": 1, "reason": "wrong_answer", "expected": "a 1\nc 3\nd 4\nb 2", "got": "d 100000000\nc 100000000\nb 99999999\na 100000000"}, {"idx": 2, "reason": "wrong_answer", "expected": "ardaae 1\nctetnl 2\nfrb 3\nhgk 4\nqgbokh 23\navcygg 6\nbczzdfvjkh 7\nekmjrgxylj 10\nm 11\nmxgdulijf 12\nojaubfibf 22\nntvvx 14\nuxpelsmxx...
codeforces
C
430
141_C. Queue
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him. After a while the cashier has a lunch break and t...
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n, nop, i, j, k, l, a, temp; char b[100]; string stt[3010]; vector<pair<int, string> > vct; vector<int> v2, v3; cin >> n; nop = n; for (i = 0; i < n; i++) { cin >> stt[i] >> a; vct.push_back(make_pair(a, stt[i])); v2.push_back(i)...
partial
12
14
[{"idx": 7, "reason": "wrong_answer", "expected": "q 1\na 2\nz 3\nw 4\ns 5\nx 6\ne 7\nd 8\nc 9\nr 10\nf 11\nv 12\nt 13\ng 14\nb 15\ny 16\nh 17\nn 18\nu 19\nj 20\nm 21\ni 22\nk 23\no 24\nl 25\np 26\nqq 27\naa 28\nzz 29\nww 30\nss 31\nxx 32\nee 33\ndd 34\ncc 35\nrr 36\nff 37\nvv 38\ntt 39\ng", "got": "a 1\naa 2\nb 3\nbb ...
codeforces
C
430
141_C. Queue
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him. After a while the cashier has a lunch break and t...
java
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Scanner; im...
partial
10
14
[{"idx": 2, "reason": "wrong_answer", "expected": "ardaae 1\nctetnl 2\nfrb 3\nhgk 4\nqgbokh 23\navcygg 6\nbczzdfvjkh 7\nekmjrgxylj 10\nm 11\nmxgdulijf 12\nojaubfibf 22\nntvvx 14\nuxpelsmxxq 21\nlowoz 15\notjmjmvpz 20\nfgtxkw 17\ngbixtuotft 18\nmnfg 19\nnu 16\nnninr 13\nx", "got": "qgbokh 1\nfrb 2\nardaae 3\nctetnl 4\nh...
codeforces
C
430
141_C. Queue
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him. After a while the cashier has a lunch break and t...
cpp
#include <bits/stdc++.h> using namespace std; int X[] = {0, 0, 1, 0, 0, -1}; int Y[] = {0, 1, 0, 0, -1, 0}; int Z[] = {1, 0, 0, -1, 0, 0}; struct node { int x; string s; node() {} node(int x, string s) : x(x), s(s) {} bool operator<(const node& p) const { return x < p.x; } }; node ara[10003]; int val[10000]; ...
partial
9
14
[{"idx": 2, "reason": "wrong_answer", "expected": "ardaae 1\nctetnl 2\nfrb 3\nhgk 4\nqgbokh 23\navcygg 6\nbczzdfvjkh 7\nekmjrgxylj 10\nm 11\nmxgdulijf 12\nojaubfibf 22\nntvvx 14\nuxpelsmxxq 21\nlowoz 15\notjmjmvpz 20\nfgtxkw 17\ngbixtuotft 18\nmnfg 19\nnu 16\nnninr 13\nx", "got": "qgbokh 1\nfrb 2\nardaae 3\nctetnl 4\nh...
codeforces
C
430
141_C. Queue
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him. After a while the cashier has a lunch break and t...
java
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class Main1 { public static void main...
partial
3
14
[{"idx": 1, "reason": "wrong_answer", "expected": "a 1\nc 3\nd 4\nb 2", "got": "d 9998\nc 9999\nb 9997\na 10000"}, {"idx": 2, "reason": "wrong_answer", "expected": "ardaae 1\nctetnl 2\nfrb 3\nhgk 4\nqgbokh 23\navcygg 6\nbczzdfvjkh 7\nekmjrgxylj 10\nm 11\nmxgdulijf 12\nojaubfibf 22\nntvvx 14\nuxpelsmxxq 21\nlowoz 15\not...
codeforces
C
430
141_C. Queue
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him. After a while the cashier has a lunch break and t...
cpp
#include <bits/stdc++.h> using namespace std; int n; struct pe { char na[20]; int bef, h; bool operator<(const pe& b) const { return bef < b.bef; } } a[3005]; char ch[20]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%s%d", a[i].na, &a[i].bef); a[i].h = 1; } sort(a + 1, a + ...
partial
4
14
[{"idx": 1, "reason": "wrong_answer", "expected": "a 1\nc 3\nd 4\nb 2", "got": "a 1\nc 49999\nd 49999\nb 1"}, {"idx": 2, "reason": "wrong_answer", "expected": "ardaae 1\nctetnl 2\nfrb 3\nhgk 4\nqgbokh 23\navcygg 6\nbczzdfvjkh 7\nekmjrgxylj 10\nm 11\nmxgdulijf 12\nojaubfibf 22\nntvvx 14\nuxpelsmxxq 21\nlowoz 15\notjmjmv...
codeforces
C
430
141_C. Queue
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him. After a while the cashier has a lunch break and t...
python2
info = [] ans = [] n = input() for i in range(n): b = raw_input().split() info.append([b[0], int(b[1])]) info.sort(key = lambda x : x[1]) for j, i in enumerate(info): if(i[1] > j): print -1 break ans.insert(i[1], (i[0], n - j)) else: for i in ans: print i[0], i[1]
partial
6
14
[{"idx": 1, "reason": "wrong_answer", "expected": "a 1\nc 3\nd 4\nb 2", "got": "d 2\nc 3\nb 1\na 4"}, {"idx": 2, "reason": "wrong_answer", "expected": "ardaae 1\nctetnl 2\nfrb 3\nhgk 4\nqgbokh 23\navcygg 6\nbczzdfvjkh 7\nekmjrgxylj 10\nm 11\nmxgdulijf 12\nojaubfibf 22\nntvvx 14\nuxpelsmxxq 21\nlowoz 15\notjmjmvpz 20\nf...
codeforces
C
430
141_C. Queue
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him. After a while the cashier has a lunch break and t...
python2
n = int(raw_input()) lis = [] for i in range(n): l = raw_input().split() lis.append((l[0], int(l[1]))) lis.sort(key = lambda x: x[1]) possible = True for i in range(len(lis)): if lis[i][1] > i: possible = False break if not possible: print -1 else: liss = [] count = 1...
partial
10
14
[{"idx": 2, "reason": "wrong_answer", "expected": "ardaae 1\nctetnl 2\nfrb 3\nhgk 4\nqgbokh 23\navcygg 6\nbczzdfvjkh 7\nekmjrgxylj 10\nm 11\nmxgdulijf 12\nojaubfibf 22\nntvvx 14\nuxpelsmxxq 21\nlowoz 15\notjmjmvpz 20\nfgtxkw 17\ngbixtuotft 18\nmnfg 19\nnu 16\nnninr 13\nx", "got": "qgbokh 1\nfrb 2\nardaae 3\nctetnl 4\nh...
codeforces
C
430
141_C. Queue
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him. After a while the cashier has a lunch break and t...
python3
def solve(arr,n): arr.sort() names = [x[1] for x in arr] counts = [x[0] for x in arr] segments = [] curr_count = counts[0] curr_len = 0 L = 0 for i in range(n): if counts[i]==curr_count: curr_len += 1 else: segments.append((L,i-1)) ...
partial
4
14
[{"idx": 1, "reason": "wrong_answer", "expected": "a 1\nc 3\nd 4\nb 2", "got": "a 1\nc 999999999\nd 999999999\nb 1"}, {"idx": 2, "reason": "wrong_answer", "expected": "ardaae 1\nctetnl 2\nfrb 3\nhgk 4\nqgbokh 23\navcygg 6\nbczzdfvjkh 7\nekmjrgxylj 10\nm 11\nmxgdulijf 12\nojaubfibf 22\nntvvx 14\nuxpelsmxxq 21\nlowoz 15\...
codeforces
C
430
141_C. Queue
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him. After a while the cashier has a lunch break and t...
python3
n = int(input()) a = [] for _ in range(n): x = input().split() a.append((x[0], int(x[1]))) a.sort(key=lambda x: x[1]) ans = [] for x in a: if x[1] > len(ans): print(-1) exit() ans.insert(x[1], (x[0], n)) n -= 1 for x in ans: print(x[0], x[1])
partial
6
14
[{"idx": 1, "reason": "wrong_answer", "expected": "a 1\nc 3\nd 4\nb 2", "got": "d 2\nc 3\nb 1\na 4"}, {"idx": 2, "reason": "wrong_answer", "expected": "ardaae 1\nctetnl 2\nfrb 3\nhgk 4\nqgbokh 23\navcygg 6\nbczzdfvjkh 7\nekmjrgxylj 10\nm 11\nmxgdulijf 12\nojaubfibf 22\nntvvx 14\nuxpelsmxxq 21\nlowoz 15\notjmjmvpz 20\nf...
codeforces
C
430
141_C. Queue
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him. After a while the cashier has a lunch break and t...
python2
from sys import stdin rstrs = lambda: [str(x) for x in stdin.readline().split()] n = int(input()) s, ans = sorted([rstrs() for _ in range(n)], key=lambda x: int(x[1])), [] # print(s) for i in range(n): if int(s[i][1]) > i: print(-1) exit() ans.insert(int(s[i][1]), ' '.join([s[i][0], str(n)]))...
partial
6
14
[{"idx": 1, "reason": "wrong_answer", "expected": "a 1\nc 3\nd 4\nb 2", "got": "d 2\nc 3\nb 1\na 4"}, {"idx": 2, "reason": "wrong_answer", "expected": "ardaae 1\nctetnl 2\nfrb 3\nhgk 4\nqgbokh 23\navcygg 6\nbczzdfvjkh 7\nekmjrgxylj 10\nm 11\nmxgdulijf 12\nojaubfibf 22\nntvvx 14\nuxpelsmxxq 21\nlowoz 15\notjmjmvpz 20\nf...
codeforces
C
430
141_C. Queue
In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai — how many people who are taller than him/her and stand in queue in front of him. After a while the cashier has a lunch break and t...
python3
n=int(input()) arr=[] for i in range(n): a,b=input().split() arr.append([a,int(b)]) arr.sort(key=lambda x:x[1]) ans=[] #print(arr) for x in arr: if x[1]>len(ans): print(-1) exit() ans.insert(x[1],(x[0],n)) n-=1 for x in ans:print(x[0],x[1])
partial
6
14
[{"idx": 1, "reason": "wrong_answer", "expected": "a 1\nc 3\nd 4\nb 2", "got": "d 2\nc 3\nb 1\na 4"}, {"idx": 2, "reason": "wrong_answer", "expected": "ardaae 1\nctetnl 2\nfrb 3\nhgk 4\nqgbokh 23\navcygg 6\nbczzdfvjkh 7\nekmjrgxylj 10\nm 11\nmxgdulijf 12\nojaubfibf 22\nntvvx 14\nuxpelsmxxq 21\nlowoz 15\notjmjmvpz 20\nf...
codeforces
C
431
1438_C. Engineer Artem
Artem is building a new robot. He has a matrix a consisting of n rows and m columns. The cell located on the i-th row from the top and the j-th column from the left has a value a_{i,j} written in it. If two adjacent cells contain the same value, the robot will break. A matrix is called good if no two adjacent cells c...
python3
def solve(): input_str = input().split() m, n = int(input_str[0]), int(input_str[1]) nums = [] for i in range(m): nums.append(list(map(int, input().split()))) for i in range(m): for j in range(n): if (i + j) & 1 == 0: if nums[i][j] & 1 == 0: ...
all_fail
0
3
[{"idx": 0, "reason": "wrong_answer", "expected": "2 3\n5 6\n8 9\n2 1\n3 4\n2 3\n3 2", "got": "1 2\n4 5\n7 8\n1 2\n4 3\n1 4\n2 3"}, {"idx": 1, "reason": "wrong_answer", "expected": "2 1 2 1 2 1 2 1 2 1\n1 2 1 2 1 2 1 2 1 2\n2 1 2 1 2 1 2 1 2 1\n1 2 1 2 1 2 1 2 1 2\n2 1 2 1 2 1 2 1 2 1\n1 2 1 2 1 2 1 2 1 2\n2 1 2 1 2 1 ...
codeforces
C
432
1463_B. Find The Array
You are given an array [a_1, a_2, ..., a_n] such that 1 ≤ a_i ≤ 10^9. Let S be the sum of all elements of the array a. Let's call an array b of n integers beautiful if: * 1 ≤ b_i ≤ 10^9 for each i from 1 to n; * for every pair of adjacent integers from the array (b_i, b_{i + 1}), either b_i divides b_{i + 1}, or...
python3
for _ in range(int(input())): n = map(int, input().split()) a = list(map(int, input().split())) c = 1 i = 0 while c <= 1000000000: d = 2 * c if c <= a[i] <= d: print(c, end=" ") i += 1 d = 1 if i == len(a): break c = d ...
partial
2
20
[{"idx": 0, "reason": "wrong_answer", "expected": "\n3 3 3 3 3\n3 6\n1 1000000000\n4 4 8 1 3 3", "got": "1 1 2 2 4\n2 4\n1 536870912\n2 2 4 1 1 2"}, {"idx": 1, "reason": "wrong_answer", "expected": "1000000000 1 500000001 1 500000001 1 500000001 1 500000001 1", "got": "536870912 268435456 268435456 268435456 268435456 ...
codeforces
B
432
1463_B. Find The Array
You are given an array [a_1, a_2, ..., a_n] such that 1 ≤ a_i ≤ 10^9. Let S be the sum of all elements of the array a. Let's call an array b of n integers beautiful if: * 1 ≤ b_i ≤ 10^9 for each i from 1 to n; * for every pair of adjacent integers from the array (b_i, b_{i + 1}), either b_i divides b_{i + 1}, or...
python3
for _ in range(int(input())): n = int(input()) a = [x for x in map(int,input().split())] odd= 0;even=0 for i in range(n): if i%2==0: odd+=abs(a[i]-1) else: even +=abs(a[i]-1) if odd>even: for i in range(n): if i%2==1: print(...
partial
16
20
[{"idx": 0, "reason": "wrong_answer", "expected": "\n3 3 3 3 3\n3 6\n1 1000000000\n4 4 8 1 3 3", "got": "1 1 3 1 5\n1 6\n1 1000000000\n3 1 8 1 2 1"}, {"idx": 8, "reason": "wrong_answer", "expected": "1 2 1 4 1\n1 6\n1 1000000000\n1 4 1 1 1 3", "got": "1 1 3 1 5\n1 6\n1 1000000000\n3 1 8 1 2 1"}, {"idx": 9, "reason": "w...
codeforces
B
432
1463_B. Find The Array
You are given an array [a_1, a_2, ..., a_n] such that 1 ≤ a_i ≤ 10^9. Let S be the sum of all elements of the array a. Let's call an array b of n integers beautiful if: * 1 ≤ b_i ≤ 10^9 for each i from 1 to n; * for every pair of adjacent integers from the array (b_i, b_{i + 1}), either b_i divides b_{i + 1}, or...
python3
import math for _ in range(int(input())): n=int(input()) l=list(map(int,input().split())) k=[] for i in l: x=int(math.log(i,2)) k.append(2**x) print(*k)
partial
2
20
[{"idx": 0, "reason": "wrong_answer", "expected": "\n3 3 3 3 3\n3 6\n1 1000000000\n4 4 8 1 3 3", "got": "1 2 2 4 4\n4 4\n1 536870912\n2 4 8 1 2 2"}, {"idx": 1, "reason": "wrong_answer", "expected": "1000000000 1 500000001 1 500000001 1 500000001 1 500000001 1", "got": "536870912 268435456 268435456 268435456 268435456 ...
codeforces
B
432
1463_B. Find The Array
You are given an array [a_1, a_2, ..., a_n] such that 1 ≤ a_i ≤ 10^9. Let S be the sum of all elements of the array a. Let's call an array b of n integers beautiful if: * 1 ≤ b_i ≤ 10^9 for each i from 1 to n; * for every pair of adjacent integers from the array (b_i, b_{i + 1}), either b_i divides b_{i + 1}, or...
cpp
// // Created by Ильдар Ялалов on 14.01.2020. // //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; const int inf_int =...
partial
16
20
[{"idx": 0, "reason": "wrong_answer", "expected": "\n3 3 3 3 3\n3 6\n1 1000000000\n4 4 8 1 3 3", "got": "1 1 3 1 5\n1 6\n1 1000000000\n3 1 8 1 2 1"}, {"idx": 8, "reason": "wrong_answer", "expected": "1 2 1 4 1\n1 6\n1 1000000000\n1 4 1 1 1 3", "got": "1 1 3 1 5\n1 6\n1 1000000000\n3 1 8 1 2 1"}, {"idx": 9, "reason": "w...
codeforces
B
432
1463_B. Find The Array
You are given an array [a_1, a_2, ..., a_n] such that 1 ≤ a_i ≤ 10^9. Let S be the sum of all elements of the array a. Let's call an array b of n integers beautiful if: * 1 ≤ b_i ≤ 10^9 for each i from 1 to n; * for every pair of adjacent integers from the array (b_i, b_{i + 1}), either b_i divides b_{i + 1}, or...
java
import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner in=new Scanner(System.in); int t=in.nextInt(); while(t-->0) { ...
partial
16
20
[{"idx": 0, "reason": "wrong_answer", "expected": "\n3 3 3 3 3\n3 6\n1 1000000000\n4 4 8 1 3 3", "got": "1 1 3 1 5\n1 6\n1 1000000000\n3 1 8 1 2 1"}, {"idx": 8, "reason": "wrong_answer", "expected": "1 2 1 4 1\n1 6\n1 1000000000\n1 4 1 1 1 3", "got": "1 1 3 1 5\n1 6\n1 1000000000\n3 1 8 1 2 1"}, {"idx": 9, "reason": "w...
codeforces
B
432
1463_B. Find The Array
You are given an array [a_1, a_2, ..., a_n] such that 1 ≤ a_i ≤ 10^9. Let S be the sum of all elements of the array a. Let's call an array b of n integers beautiful if: * 1 ≤ b_i ≤ 10^9 for each i from 1 to n; * for every pair of adjacent integers from the array (b_i, b_{i + 1}), either b_i divides b_{i + 1}, or...
cpp
#include <bits/stdc++.h> using namespace std; #define ll long long int int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll t; cin>>t; while(t--) { ll n; cin>>n; ll a[n+1],even_sum=0,sum=0; a[0]=0; for(ll i=1;i<=n;i++) { cin>>a[i]; if...
partial
16
20
[{"idx": 0, "reason": "wrong_answer", "expected": "\n3 3 3 3 3\n3 6\n1 1000000000\n4 4 8 1 3 3", "got": "1 1 3 1 5\n1 6\n1 1000000000\n3 1 8 1 2 1"}, {"idx": 8, "reason": "wrong_answer", "expected": "1 2 1 4 1\n1 6\n1 1000000000\n1 4 1 1 1 3", "got": "1 1 3 1 5\n1 6\n1 1000000000\n3 1 8 1 2 1"}, {"idx": 9, "reason": "w...
codeforces
B
432
1463_B. Find The Array
You are given an array [a_1, a_2, ..., a_n] such that 1 ≤ a_i ≤ 10^9. Let S be the sum of all elements of the array a. Let's call an array b of n integers beautiful if: * 1 ≤ b_i ≤ 10^9 for each i from 1 to n; * for every pair of adjacent integers from the array (b_i, b_{i + 1}), either b_i divides b_{i + 1}, or...
java
import java.util.*; import java.io.*; //import java.math.*; public class Task{ // ..............code begins here.............. // 001010 - 10 // 110010 - 50 // 001001 - 9 static long mod=(long)1e9+7; static void solve() throws IOException { int n=int_v(read()); int[] a=int_arr(); lon...
partial
2
20
[{"idx": 0, "reason": "wrong_answer", "expected": "\n3 3 3 3 3\n3 6\n1 1000000000\n4 4 8 1 3 3", "got": "1 2 2 4 4\n4 4\n1 536870912\n2 4 8 1 2 2"}, {"idx": 1, "reason": "wrong_answer", "expected": "1000000000 1 500000001 1 500000001 1 500000001 1 500000001 1", "got": "536870912 268435456 268435456 268435456 268435456 ...
codeforces
B
432
1463_B. Find The Array
You are given an array [a_1, a_2, ..., a_n] such that 1 ≤ a_i ≤ 10^9. Let S be the sum of all elements of the array a. Let's call an array b of n integers beautiful if: * 1 ≤ b_i ≤ 10^9 for each i from 1 to n; * for every pair of adjacent integers from the array (b_i, b_{i + 1}), either b_i divides b_{i + 1}, or...
java
/* ⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀⢠⠞⠉⠙⠲⡀⠀ ⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀⡏⠀⠀Y⠀⠀⢷ ⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀⢸⠀⠀A⠀⠀ ⡇ ⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀⣸⠀⠀S⠀ ⡇ ⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀⢹⠀⠀H⠀⠀ ⡇ ⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀⡇⠀⠀⠀⠀⡼ ⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀⠘⠤⣄⣠⠞⠀ ⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀ ⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀ ⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀ ⣿⣿⣧⣀⣿………⣀⣰⣏⣘⣆⣀⠀⠀ */ import java.io.BufferedReader; impo...
partial
16
20
[{"idx": 0, "reason": "wrong_answer", "expected": "\n3 3 3 3 3\n3 6\n1 1000000000\n4 4 8 1 3 3", "got": "1 1 3 1 5\n1 6\n1 1000000000\n3 1 8 1 2 1"}, {"idx": 8, "reason": "wrong_answer", "expected": "1 2 1 4 1\n1 6\n1 1000000000\n1 4 1 1 1 3", "got": "1 1 3 1 5\n1 6\n1 1000000000\n3 1 8 1 2 1"}, {"idx": 9, "reason": "w...
codeforces
B
432
1463_B. Find The Array
You are given an array [a_1, a_2, ..., a_n] such that 1 ≤ a_i ≤ 10^9. Let S be the sum of all elements of the array a. Let's call an array b of n integers beautiful if: * 1 ≤ b_i ≤ 10^9 for each i from 1 to n; * for every pair of adjacent integers from the array (b_i, b_{i + 1}), either b_i divides b_{i + 1}, or...
cpp
#include<bits/stdc++.h> using namespace std; #define ll long long ll n; void solve() { cin >> n; ll sum = 0; vector<ll> arr(n); for (ll i = 0; i < n; i++) {cin >> arr[i]; sum += arr[i];} ll temps = 0; for (ll i = 0; i < n; i += 2) { temps += arr[i] - 1; } vector<ll> ans(n); if (temps < ceil((1.0 * sum)...
all_fail
0
20
[{"idx": 0, "reason": "wrong_answer", "expected": "\n3 3 3 3 3\n3 6\n1 1000000000\n4 4 8 1 3 3", "got": ""}, {"idx": 1, "reason": "wrong_answer", "expected": "1000000000 1 500000001 1 500000001 1 500000001 1 500000001 1", "got": ""}, {"idx": 2, "reason": "wrong_answer", "expected": "818 1 386 1 110 1 49\n694 1 511 1 30...
codeforces
B
432
1463_B. Find The Array
You are given an array [a_1, a_2, ..., a_n] such that 1 ≤ a_i ≤ 10^9. Let S be the sum of all elements of the array a. Let's call an array b of n integers beautiful if: * 1 ≤ b_i ≤ 10^9 for each i from 1 to n; * for every pair of adjacent integers from the array (b_i, b_{i + 1}), either b_i divides b_{i + 1}, or...
python2
for _ in range(input()): n=input() a=map(int,raw_input().split()) b=[] c=[] f,g=0,0 for i in range(n): if i%2: b.append(1);c.append(a[i]) f+=(a[i]-1) else: c.append(1);b.append(a[i]) g+=(a[i]-1) s="" if 2*f<=sum...
partial
13
20
[{"idx": 0, "reason": "wrong_answer", "expected": "\n3 3 3 3 3\n3 6\n1 1000000000\n4 4 8 1 3 3", "got": "1 1 3 1 5\n4 1\n1 1000000000\n3 1 8 1 2 1"}, {"idx": 5, "reason": "wrong_answer", "expected": "1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 8 1 8 1 8 1 8 1 8 1 8 1 8 1 8 1 8 1 8 1 8 1 15", "got": "1 1 2 1 2...
codeforces
B
432
1463_B. Find The Array
You are given an array [a_1, a_2, ..., a_n] such that 1 ≤ a_i ≤ 10^9. Let S be the sum of all elements of the array a. Let's call an array b of n integers beautiful if: * 1 ≤ b_i ≤ 10^9 for each i from 1 to n; * for every pair of adjacent integers from the array (b_i, b_{i + 1}), either b_i divides b_{i + 1}, or...
python2
from math import log for test in range(input()): n = input() a = (map(int,raw_input().split())) ans = [] ans2 = [] d = 0 e = 0 s = sum(a) for i in range(n): if i%2==0: ans.append(1) d += abs(a[i]-1) ans2.append(a[i]) else: a...
partial
19
20
[{"idx": 0, "reason": "wrong_answer", "expected": "\n3 3 3 3 3\n3 6\n1 1000000000\n4 4 8 1 3 3", "got": "1 2 1 4 1\n1 6\n1 1000000000\n1 4 1 1 1 3"}]
codeforces
B
432
1463_B. Find The Array
You are given an array [a_1, a_2, ..., a_n] such that 1 ≤ a_i ≤ 10^9. Let S be the sum of all elements of the array a. Let's call an array b of n integers beautiful if: * 1 ≤ b_i ≤ 10^9 for each i from 1 to n; * for every pair of adjacent integers from the array (b_i, b_{i + 1}), either b_i divides b_{i + 1}, or...
python2
for _ in range(input()): n = input() a = map(int,raw_input().split()) s = [0,0] for i in range(n): s[i%2] += a[i] if s[0] < s[1]: a = map(lambda (i, v): 1 if (i%2 == 0) else v, enumerate(a)) else: a = map(lambda (i, v): 1 if (i%2 == 1) else v, enumerate(a)) for i in a...
partial
16
20
[{"idx": 0, "reason": "wrong_answer", "expected": "\n3 3 3 3 3\n3 6\n1 1000000000\n4 4 8 1 3 3", "got": "1 1 3 1 5\n1 6\n1 1000000000\n3 1 8 1 2 1"}, {"idx": 8, "reason": "wrong_answer", "expected": "1 2 1 4 1\n1 6\n1 1000000000\n1 4 1 1 1 3", "got": "1 1 3 1 5\n1 6\n1 1000000000\n3 1 8 1 2 1"}, {"idx": 9, "reason": "w...
codeforces
B
433
148_B. Escape
The princess is going to escape the dragon's cave, and she needs to plan it carefully. The princess runs at vp miles per hour, and the dragon flies at vd miles per hour. The dragon will discover the escape after t hours and will chase the princess immediately. Looks like there's no chance to success, but the princess ...
java
import java.io.*; import java.util.*; import static java.lang.Math.*; public class B implements Runnable { BufferedReader in; PrintWriter out; StringTokenizer tok; public static void main(String[] args) { new Thread(null, new B(), "", 256*1024*1024).start(); } @Override public void run() { try { long...
all_fail
0
25
[{"idx": 0, "reason": "runtime_error", "rc": 255, "stderr": "java.io.FileNotFoundException: input.txt (No such file or directory)\n\tat java.base/java.io.FileInputStream.open0(Native Method)\n\tat java.base/java.io.FileInputStream.open(FileInputStream.java:216)\n\tat", "stdout_tail": ""}, {"idx": 1, "reason": "runtime_...
codeforces
B
436
187_B. AlgoRace
PMP is getting a warrior. He is practicing a lot, but the results are not acceptable yet. This time instead of programming contests, he decided to compete in a car racing to increase the spirit of victory. He decides to choose a competition that also exhibits algorithmic features. AlgoRace is a special league of car r...
java
//package round119; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; public class B2 { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n = ni(), m = ni(), r = ni(); int[][][] g = new int[m...
all_fail
0
8
[{"idx": 0, "reason": "runtime_error", "rc": 1, "stderr": "Exception in thread \"main\" java.lang.NegativeArraySizeException: -49\n\tat B2.solve(B2.java:16)\n\tat B2.run(B2.java:78)\n\tat B2.main(B2.java:85)\n", "stdout_tail": ""}, {"idx": 1, "reason": "runtime_error", "rc": 1, "stderr": "Exception in thread \"main\" j...
codeforces
B
437
233_C. Cycles
John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3. A cycle of length 3 is an unordered group of three distinct graph vertices a, b and c, such that each pair of them is connected by a graph edge. John has been pa...
java
import java.util.*; import java.io.*; import java.math.*; public class Main1 { static class Reader { private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;} public int read() {if (n...
all_fail
0
25
[{"idx": 0, "reason": "wrong_answer", "expected": "5\n01111\n10111\n11011\n11101\n11110", "got": "100\n0111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n10111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}, {"idx": 1, "reas...
codeforces
C
437
233_C. Cycles
John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3. A cycle of length 3 is an unordered group of three distinct graph vertices a, b and c, such that each pair of them is connected by a graph edge. John has been pa...
java
import java.util.ArrayList; import java.util.Scanner; public class C { static ArrayList<ArrayList<Integer>> graph; static void init() { graph = new ArrayList<ArrayList<Integer>>(); graph.add(new ArrayList<Integer>()); graph.add(new ArrayList<Integer>()); graph.add(new ArrayList<Integer>()); graph.get(0)....
partial
10
25
[{"idx": 4, "reason": "wrong_answer", "expected": "5\n01111\n10111\n11010\n11100\n11000", "got": "5\n01110\n10111\n11010\n11101\n01010"}, {"idx": 6, "reason": "wrong_answer", "expected": "5\n01111\n10111\n11011\n11100\n11100", "got": "5\n01110\n10111\n11011\n11101\n01110"}, {"idx": 8, "reason": "wrong_answer", "expecte...
codeforces
C
437
233_C. Cycles
John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3. A cycle of length 3 is an unordered group of three distinct graph vertices a, b and c, such that each pair of them is connected by a graph edge. John has been pa...
python3
import sys import math c=int(input()) Ans=[] F=[1] for i in range(1,101): F.append(F[-1]*i) for i in range(100): Ans.append([0]*100) print(100) cycles=1 Ans[0][1]=1 Ans[1][0]=1 Ans[1][2]=1 Ans[2][1]=1 Ans[0][2]=1 Ans[2][0]=1 m=3 while(cycles<c): Ans[0][m]=1 Ans[m][0]=1 inc=1 for j in range(1...
all_fail
0
25
[{"idx": 0, "reason": "wrong_answer", "expected": "5\n01111\n10111\n11011\n11101\n11110", "got": "100\n0111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n10111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}, {"idx": 1, "reas...
codeforces
C
438
282_B. Painting Eggs
The Bitlandians are quite weird people. They have very peculiar customs. As is customary, Uncle J. wants to have n eggs painted for Bitruz (an ancient Bitland festival). He has asked G. and A. to do the work. The kids are excited because just as is customary, they're going to be paid for the job! Overall uncle J. h...
cpp
#include <bits/stdc++.h> using namespace std; pair<long long, long long> dp[3][1000005]; int A[1000005], B[1000005]; int ma[3][1000005]; int main() { int n, x; pair<int, int> e1; pair<int, int> e2; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d%d", &A[i], &B[i]); dp[0][0] = make_pair(A[0], 0); dp[...
partial
5
10
[{"idx": 0, "reason": "wrong_answer", "expected": "AG", "got": "GA"}, {"idx": 1, "reason": "wrong_answer", "expected": "AGA", "got": "GAA"}, {"idx": 3, "reason": "wrong_answer", "expected": "AG", "got": "GA"}, {"idx": 5, "reason": "wrong_answer", "expected": "AG", "got": "GA"}, {"idx": 9, "reason": "wrong_answer", "exp...
codeforces
B
438
282_B. Painting Eggs
The Bitlandians are quite weird people. They have very peculiar customs. As is customary, Uncle J. wants to have n eggs painted for Bitruz (an ancient Bitland festival). He has asked G. and A. to do the work. The kids are excited because just as is customary, they're going to be paid for the job! Overall uncle J. h...
cpp
#include <bits/stdc++.h> int a[1000000]; int aa[1000000]; int g[1000000]; int gg[1000000]; char ans[1000001]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%d %d", &a[i], &g[i]); if (i == 0) { aa[i] = a[i]; gg[i] = g[i]; } else { aa[i] = aa[i - 1] + a[i]; ...
partial
8
10
[{"idx": 1, "reason": "wrong_answer", "expected": "AGA", "got": "AAG"}, {"idx": 9, "reason": "wrong_answer", "expected": "AGA", "got": "AAG"}]
codeforces
B
438
282_B. Painting Eggs
The Bitlandians are quite weird people. They have very peculiar customs. As is customary, Uncle J. wants to have n eggs painted for Bitruz (an ancient Bitland festival). He has asked G. and A. to do the work. The kids are excited because just as is customary, they're going to be paid for the job! Overall uncle J. h...
python3
n = int(input()) k = (sum(int(input().split()[0]) for i in range(n))+499)//1000 print('G'*k+'A'*(n-k)) # Made By Mostafa_Khaled
partial
5
10
[{"idx": 0, "reason": "wrong_answer", "expected": "AG", "got": "GA"}, {"idx": 1, "reason": "wrong_answer", "expected": "AGA", "got": "GAA"}, {"idx": 3, "reason": "wrong_answer", "expected": "AG", "got": "GA"}, {"idx": 5, "reason": "wrong_answer", "expected": "AG", "got": "GA"}, {"idx": 9, "reason": "wrong_answer", "exp...
codeforces
B
439
305_A. Strange Addition
Unfortunately, Vasya can only sum pairs of integers (a, b), such that for any decimal place at least one number has digit 0 in this place. For example, Vasya can sum numbers 505 and 50, but he cannot sum 1 and 4. Vasya has a set of k distinct non-negative integers d1, d2, ..., dk. Vasya wants to choose some integers ...
cpp
#include <bits/stdc++.h> using namespace std; int n, arr[100], i, j; bool a[100][100]; bool Ok(int x, int y) { while (x && y) { int a = x % 10; int b = y % 10; x /= 10; y /= 10; if (a && b) return false; } return true; } int main() { cin >> n; vector<vector<int> > v; for (int i = 0; i < ...
partial
22
25
[{"idx": 12, "reason": "wrong_answer", "expected": "3\n0 100 23", "got": "3\n23 0 100"}, {"idx": 13, "reason": "wrong_answer", "expected": "3\n0 100 6", "got": "3\n99 0 100"}, {"idx": 22, "reason": "wrong_answer", "expected": "1\n70", "got": "1\n23"}]
codeforces
A
439
305_A. Strange Addition
Unfortunately, Vasya can only sum pairs of integers (a, b), such that for any decimal place at least one number has digit 0 in this place. For example, Vasya can sum numbers 505 and 50, but he cannot sum 1 and 4. Vasya has a set of k distinct non-negative integers d1, d2, ..., dk. Vasya wants to choose some integers ...
cpp
#include <bits/stdc++.h> int vis[111]; int a[111]; int main() { int i, j, n; int v; while (scanf("%d", &n) != EOF) { memset(vis, -1, sizeof(vis)); int flag = 0; int tt = 0; for (i = 1; i <= n; i++) { scanf("%d", &v); if (v == 100) vis[1] = 100; else if (v == 0) vi...
partial
5
25
[{"idx": 0, "reason": "wrong_answer", "expected": "4\n100 10 1 0", "got": "4\n100 0 1 10"}, {"idx": 1, "reason": "wrong_answer", "expected": "2\n2 70", "got": "2\n3 70"}, {"idx": 3, "reason": "wrong_answer", "expected": "4\n70 100 6 0", "got": "4\n100 0 6 70"}, {"idx": 4, "reason": "wrong_answer", "expected": "2\n10 6"...
codeforces
A
439
305_A. Strange Addition
Unfortunately, Vasya can only sum pairs of integers (a, b), such that for any decimal place at least one number has digit 0 in this place. For example, Vasya can sum numbers 505 and 50, but he cannot sum 1 and 4. Vasya has a set of k distinct non-negative integers d1, d2, ..., dk. Vasya wants to choose some integers ...
java
import java.util.ArrayList; import java.util.List; import java.util.Scanner; /** * Created by Yusuf on 7/27/2016. * A. Strange Addition */ public class A305 { public static int onePos(int num) { int ret = 0; for (int i = 0; i < 3; ++i) { if (num % 10 != 0) ret |= (1 << i); ...
partial
24
25
[{"idx": 17, "reason": "wrong_answer", "expected": "1\n11", "got": "1\n99"}]
codeforces
A
439
305_A. Strange Addition
Unfortunately, Vasya can only sum pairs of integers (a, b), such that for any decimal place at least one number has digit 0 in this place. For example, Vasya can sum numbers 505 and 50, but he cannot sum 1 and 4. Vasya has a set of k distinct non-negative integers d1, d2, ..., dk. Vasya wants to choose some integers ...
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> arr; int a = 0, b = 0, c = 0, d = 0, e = 0; for (int i = 0; i < n; i++) { int x; cin >> x; if (x == 0) a = 1; else if (x == 100) b = 1; else if (x % 10 == 0) c = x; else if (x < 10...
partial
15
25
[{"idx": 0, "reason": "wrong_answer", "expected": "4\n100 10 1 0", "got": "4\n0 100 10 1"}, {"idx": 1, "reason": "wrong_answer", "expected": "2\n2 70", "got": "2\n70 3"}, {"idx": 3, "reason": "wrong_answer", "expected": "4\n70 100 6 0", "got": "4\n0 100 60 6"}, {"idx": 9, "reason": "wrong_answer", "expected": "1\n5", "...
codeforces
A
439
305_A. Strange Addition
Unfortunately, Vasya can only sum pairs of integers (a, b), such that for any decimal place at least one number has digit 0 in this place. For example, Vasya can sum numbers 505 and 50, but he cannot sum 1 and 4. Vasya has a set of k distinct non-negative integers d1, d2, ..., dk. Vasya wants to choose some integers ...
python3
n = int(input()) arr = list(map(int,input().split())) t = [] flag = 0 if(0 in arr): t.append(0) if(100 in arr): t.append(100) for i in range(n): if(arr[i]>0 and arr[i]<10): t.append(arr[i]) flag = 1 break for i in range(n): if(arr[i]%10 == 0 and arr[i]>0 and arr[i]<100): ...
partial
16
25
[{"idx": 0, "reason": "wrong_answer", "expected": "4\n100 10 1 0", "got": "4\n0 100 1 10"}, {"idx": 3, "reason": "wrong_answer", "expected": "4\n70 100 6 0", "got": "4\n0 100 6 70"}, {"idx": 4, "reason": "wrong_answer", "expected": "2\n10 6", "got": "2\n6 10"}, {"idx": 11, "reason": "wrong_answer", "expected": "4\n10 0...
codeforces
A
439
305_A. Strange Addition
Unfortunately, Vasya can only sum pairs of integers (a, b), such that for any decimal place at least one number has digit 0 in this place. For example, Vasya can sum numbers 505 and 50, but he cannot sum 1 and 4. Vasya has a set of k distinct non-negative integers d1, d2, ..., dk. Vasya wants to choose some integers ...
java
import static java.lang.System.in; import static java.lang.System.out; import java.util.Scanner; public class A305 { public static Scanner sc=new Scanner(in); public void run(){ // TODO Auto-generated method stub int n=sc.nextInt(); boolean zero=false,hund=false; int ans=0; int ju=0, non=0; int may=0;...
partial
15
25
[{"idx": 0, "reason": "wrong_answer", "expected": "4\n100 10 1 0", "got": "4\n0 100 10 1"}, {"idx": 1, "reason": "wrong_answer", "expected": "2\n2 70", "got": "2\n70 3"}, {"idx": 3, "reason": "wrong_answer", "expected": "4\n70 100 6 0", "got": "4\n0 100 60 6"}, {"idx": 9, "reason": "wrong_answer", "expected": "1\n5", "...
codeforces
A
439
305_A. Strange Addition
Unfortunately, Vasya can only sum pairs of integers (a, b), such that for any decimal place at least one number has digit 0 in this place. For example, Vasya can sum numbers 505 and 50, but he cannot sum 1 and 4. Vasya has a set of k distinct non-negative integers d1, d2, ..., dk. Vasya wants to choose some integers ...
java
import java.util.Arrays; import java.util.Scanner; public class Prob305A { public static void main(String[] Args) { Scanner scan = new Scanner(System.in); int x = scan.nextInt(); int[] arr = new int[5]; // 0, X, X0, 100, XY Arrays.fill(arr, -1); for (int i = 0; i < x; i++) { int y = scan.nextInt(); if...
partial
9
25
[{"idx": 0, "reason": "wrong_answer", "expected": "4\n100 10 1 0", "got": "4\n0 1 10 100"}, {"idx": 1, "reason": "wrong_answer", "expected": "2\n2 70", "got": "2\n3 70"}, {"idx": 3, "reason": "wrong_answer", "expected": "4\n70 100 6 0", "got": "4\n0 6 60 100"}, {"idx": 4, "reason": "wrong_answer", "expected": "2\n10 6"...
codeforces
A
439
305_A. Strange Addition
Unfortunately, Vasya can only sum pairs of integers (a, b), such that for any decimal place at least one number has digit 0 in this place. For example, Vasya can sum numbers 505 and 50, but he cannot sum 1 and 4. Vasya has a set of k distinct non-negative integers d1, d2, ..., dk. Vasya wants to choose some integers ...
python3
# most of the errors as it took me sometime to understand it size = int(input()); z,on,pos = set(),[],0 for x in sorted(input().split(), key = lambda x: len(x)): if '0' in x: cunt = x.find('0',pos) if cunt != - 1: z.add(x); pos = cunt + 1 else: on.append(x) if z: cat = list(filter(lambda x: ...
partial
12
25
[{"idx": 0, "reason": "wrong_answer", "expected": "4\n100 10 1 0", "got": "4\n100 0 10 1"}, {"idx": 1, "reason": "wrong_answer", "expected": "2\n2 70", "got": "2\n70 2"}, {"idx": 3, "reason": "wrong_answer", "expected": "4\n70 100 6 0", "got": "4\n100 70 0 6"}, {"idx": 6, "reason": "wrong_answer", "expected": "3\n0 100...
codeforces
A
439
305_A. Strange Addition
Unfortunately, Vasya can only sum pairs of integers (a, b), such that for any decimal place at least one number has digit 0 in this place. For example, Vasya can sum numbers 505 and 50, but he cannot sum 1 and 4. Vasya has a set of k distinct non-negative integers d1, d2, ..., dk. Vasya wants to choose some integers ...
python2
from sys import stdin k = int(stdin.readline().strip()) numbers = stdin.readline().strip().split(' ') numbers = map(int, numbers) res = [] d1 = d2 = dd = 0 for d in numbers: if d == 0 or d == 100: d0 = 0 elif d % 10 == 0 and not d1: d1 = 1 elif d < 10 and not d2: d2 = 1 else: ...
partial
24
25
[{"idx": 17, "reason": "wrong_answer", "expected": "1\n11", "got": "1\n99"}]
codeforces
A
439
305_A. Strange Addition
Unfortunately, Vasya can only sum pairs of integers (a, b), such that for any decimal place at least one number has digit 0 in this place. For example, Vasya can sum numbers 505 and 50, but he cannot sum 1 and 4. Vasya has a set of k distinct non-negative integers d1, d2, ..., dk. Vasya wants to choose some integers ...
python3
size = int(input()); z,on,pos = set(),[],0 for x in sorted(input().split(), key = lambda x: len(x)): if '0' in x: cunt = x.find('0',pos) if cunt != - 1: z.add(x); pos = cunt + 1 else: on.append(x) if z: cat = list(filter(lambda x: len(x) == 2,z)) cat = len(cat[0]) if cat else 0 for o...
partial
12
25
[{"idx": 0, "reason": "wrong_answer", "expected": "4\n100 10 1 0", "got": "4\n100 0 10 1"}, {"idx": 1, "reason": "wrong_answer", "expected": "2\n2 70", "got": "2\n70 2"}, {"idx": 3, "reason": "wrong_answer", "expected": "4\n70 100 6 0", "got": "4\n6 100 0 70"}, {"idx": 4, "reason": "wrong_answer", "expected": "2\n10 6"...
codeforces
A
439
305_A. Strange Addition
Unfortunately, Vasya can only sum pairs of integers (a, b), such that for any decimal place at least one number has digit 0 in this place. For example, Vasya can sum numbers 505 and 50, but he cannot sum 1 and 4. Vasya has a set of k distinct non-negative integers d1, d2, ..., dk. Vasya wants to choose some integers ...
python2
import sys def zeros(a, b): for i in xrange(min([len(a), len(b)])): if not (a[i] == '0' or b[i] == '0'): return False return True n = int(sys.stdin.readline()) a = set(map(int, sys.stdin.readline().split())) r = set([]) if 0 in a: r.add(0) if 100 in a: r.add(100) for i in a: ...
partial
14
25
[{"idx": 0, "reason": "wrong_answer", "expected": "4\n100 10 1 0", "got": "4\n0 1 10 100"}, {"idx": 3, "reason": "wrong_answer", "expected": "4\n70 100 6 0", "got": "4\n0 100 6 30"}, {"idx": 6, "reason": "wrong_answer", "expected": "3\n0 100 10", "got": "3\n0 10 100"}, {"idx": 10, "reason": "wrong_answer", "expected": ...
codeforces
A
439
305_A. Strange Addition
Unfortunately, Vasya can only sum pairs of integers (a, b), such that for any decimal place at least one number has digit 0 in this place. For example, Vasya can sum numbers 505 and 50, but he cannot sum 1 and 4. Vasya has a set of k distinct non-negative integers d1, d2, ..., dk. Vasya wants to choose some integers ...
python2
from Queue import * # Queue, LifoQueue, PriorityQueue from bisect import * #bisect, insort from datetime import * from collections import * #deque, Counter,OrderedDict,defaultdict import calendar import heapq import math import copy import itertools def solver(): n = input() num = map(int, raw_input().split(...
partial
17
25
[{"idx": 0, "reason": "wrong_answer", "expected": "4\n100 10 1 0", "got": "4\n0 100 10 1"}, {"idx": 3, "reason": "wrong_answer", "expected": "4\n70 100 6 0", "got": "4\n0 100 70 6"}, {"idx": 11, "reason": "wrong_answer", "expected": "4\n10 0 6 100", "got": "4\n0 100 10 6"}, {"idx": 12, "reason": "wrong_answer", "expect...
codeforces
A
440
331_A2. Oh Sweet Beaverette
— Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me? — Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night? At this point the Smart Beaver got rushing. Everything should be perfect by Friday, so he needed to prepare the belt to the upcomin...
cpp
#include <bits/stdc++.h> using namespace std; map<int, int> mp; vector<int> vc; long long psum[300001]; long long a[300001]; int main() { long long ans = -2000000001; int n, ansi; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] > 0) psum[i] = psum[i - 1] + a[i]; else psum[...
partial
14
15
[{"idx": 9, "reason": "wrong_answer", "expected": "-2000000000 1\n2", "got": "-2000000000 1\n3"}]
codeforces
A
440
331_A2. Oh Sweet Beaverette
— Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me? — Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night? At this point the Smart Beaver got rushing. Everything should be perfect by Friday, so he needed to prepare the belt to the upcomin...
cpp
#include <bits/stdc++.h> using namespace std; long long sum[300008], record[300008], a[300008]; struct Tree { long long value, id; } tree[300008]; int cmp(Tree a, Tree b) { if (a.value == b.value) return a.id < b.id; else return a.value < b.value; } int main() { long long n, i, j, ans, l = 0, r = 0, tem...
partial
7
15
[{"idx": 1, "reason": "wrong_answer", "expected": "5 2\n2 5", "got": " 0 1\n 1"}, {"idx": 2, "reason": "wrong_answer", "expected": "3...
codeforces
A
440
331_A2. Oh Sweet Beaverette
— Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me? — Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night? At this point the Smart Beaver got rushing. Everything should be perfect by Friday, so he needed to prepare the belt to the upcomin...
java
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedLi...
partial
14
15
[{"idx": 9, "reason": "wrong_answer", "expected": "-2000000000 1\n2", "got": "-2000000000 1\n3"}]
codeforces
A
440
331_A2. Oh Sweet Beaverette
— Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me? — Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night? At this point the Smart Beaver got rushing. Everything should be perfect by Friday, so he needed to prepare the belt to the upcomin...
cpp
#include <bits/stdc++.h> const int MXN = 300010; int main() { int n; scanf("%d", &n); std::map<int, int> first, last; static int ary[MXN]; static int cut[MXN]; static long long sum[MXN]; for (int i = 1; i <= n; i++) { scanf("%d", &ary[i]); if (ary[i] > 0) { cut[i] = cut[i - 1]; sum[i] ...
partial
12
15
[{"idx": 2, "reason": "wrong_answer", "expected": "3000000000 0", "got": " -1294967296 0"}, {"idx": 5, "reason": "wrong_answer", "expected": "4215055101 13\n1 4 7 8 10 12 13 15 16 17 18 19 20", "got": " -79912195 1...
codeforces
A
440
331_A2. Oh Sweet Beaverette
— Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me? — Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night? At this point the Smart Beaver got rushing. Everything should be perfect by Friday, so he needed to prepare the belt to the upcomin...
java
import java.util.*; public class Solution { public static void main(String []args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int arr[] = new int[n]; long sumpre[] = new long[n]; for(int i = 0 ; i < n ; i++) { arr[i] = sc.ne...
partial
14
15
[{"idx": 9, "reason": "wrong_answer", "expected": "-2000000000 1\n2", "got": "-2000000000 1\n1"}]
codeforces
A
440
331_A2. Oh Sweet Beaverette
— Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me? — Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night? At this point the Smart Beaver got rushing. Everything should be perfect by Friday, so he needed to prepare the belt to the upcomin...
python2
n = int(raw_input().strip()) trees = [0] + [int(i) for i in raw_input().strip().split()] d = {} negtreesstartindexd = {} best = -999999999999999999999999999999 startindex = -9999 endindex = -9999 negtreesstartindex = -9999 negtreesendindex = -9999 negtrees = [] totals = [0] for i in range(1, len(trees)): if tree...
partial
14
15
[{"idx": 9, "reason": "wrong_answer", "expected": "-2000000000 1\n2", "got": "-2000000000 1\n3"}]
codeforces
A
440
331_A2. Oh Sweet Beaverette
— Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me? — Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night? At this point the Smart Beaver got rushing. Everything should be perfect by Friday, so he needed to prepare the belt to the upcomin...
python2
from sys import stdin, stdout n = int(stdin.readline()) a = map(int, stdin.readline().split()) d = dict() s = [0] for x in a: s.append(s[-1] + max(x, 0)) ans = -10 ** 30 fi = 0 for i, x in enumerate(a): if x in d: tmp = x + x + s[i] - s[d[x]+1] if ans < tmp: ans = tmp fi ...
partial
14
15
[{"idx": 9, "reason": "wrong_answer", "expected": "-2000000000 1\n2", "got": "-2000000000 1\n3"}]
codeforces
A
440
331_A2. Oh Sweet Beaverette
— Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me? — Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night? At this point the Smart Beaver got rushing. Everything should be perfect by Friday, so he needed to prepare the belt to the upcomin...
python3
n=int(input()) a=tuple(map(int,input().split())) c={} p={} s=x=y=0 m=-1e18 for i in range(0,len(a)): d=c.get(a[i]) if d!=None and s-d+a[i]*2>m: m=s-d+a[i]*2 x,y=p.get(a[i]),i if(a[i]>0):s+=a[i] if p.get(a[i])==None: p[a[i]]=i c[a[i]]=s a=[str(i+1) for i in range(0,len(a...
partial
14
15
[{"idx": 9, "reason": "wrong_answer", "expected": "-2000000000 1\n2", "got": "-2000000000 1\n3"}]
codeforces
A