exec_outcome stringclasses 1
value | code_uid stringlengths 32 32 | file_name stringclasses 111
values | prob_desc_created_at stringlengths 10 10 | prob_desc_description stringlengths 63 3.8k | prob_desc_memory_limit stringclasses 18
values | source_code stringlengths 117 65.5k | lang_cluster stringclasses 1
value | prob_desc_sample_inputs stringlengths 2 802 | prob_desc_time_limit stringclasses 27
values | prob_desc_sample_outputs stringlengths 2 796 | prob_desc_notes stringlengths 4 3k β | lang stringclasses 5
values | prob_desc_input_from stringclasses 3
values | tags listlengths 0 11 | src_uid stringlengths 32 32 | prob_desc_input_spec stringlengths 28 2.37k β | difficulty int64 -1 3.5k β | prob_desc_output_spec stringlengths 17 1.47k β | prob_desc_output_to stringclasses 3
values | hidden_unit_tests stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
PASSED | f93abf8a10f8865a6ae4d3d131bed433 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.lang.*;
import java.util.*;
import java.io.*;
public class Grid{
boolean checkInc(int[][]gArr,int r, int c){
boolean retV = false;
if(gArr[r][c]==0){
gArr[r][c]++;
retV = true;
}
return retV;
}
int[][]updateGrid(int n, int m, int[][]gArr){
for(int i=0;i<n;i++){
for(int j=0;... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 5d019fb0bfd170e89db6919d399ef073 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args)throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));
int t=Integer.par... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | bb32a2f12e651facfa77f9607ae871e4 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
public class Main {
InputStream is;
PrintWriter out;
String INPUT = "";
void solve() {
for(int T = ni(); T > 0; T--) {
int... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 08f84e2a00acd41a4b6a6a3fb4f49e44 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes |
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
public class BB {
public static void main(String[] args) {
try {
FastReader fr = new FastReader(System.in);
int t = fr.nextInt();
while (t > 0) {
... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 18f2fd343d00a4c17ffe831d10f3c74a | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes |
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class BB {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t > 0) {
t--;
int n,m;
n = sc.nextInt();
... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 82df136866246bae8734bcdc1d3b31c4 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class BB {
public static void main(String[] args) {
try {
FastReader fr = new FastReader(System.in);
int t = fr.nextInt();
while (t... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 4ff2dbfb4da6c55586ce0158c07dab23 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes |
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class BB {
public static void main(String[] args) {
try {
FastReader fr = new FastReader(System.in);
int t = fr.nextInt();
while ... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | d4448b426a2828b604209224679f764e | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes |
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class BB {
public static void main(String[] args) {
try {
FastReader fr = new FastReader(System.in);
int t = fr.nextInt();
while (... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | ba0b49ca3d43fabaa7c6fe71d8029f60 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes |
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class BB {
public static void main(String[] args) {
try {
FastReader fr = new FastReader(System.in);
int t = fr.nextInt();
while ... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | da4a6bd2d99563d46a186db162f00a97 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes |
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
public class BB {
public static void main(String[] args) {
try {
FastReader fr = new FastReader(System.in);
int t = fr.nextInt();
while (t > 0) {
t... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | e168891707098cd371bc370710f13680 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes |
import java.util.*;
import java.io.*;
public class NeighborGrid {
// https://codeforces.com/contest/1375/problem/B
public static void main(String[] args) throws IOException, FileNotFoundException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//BufferedReader in = new BufferedRea... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 1d89825f4d393b12558c5e11cad9b025 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.util.*;
public class Main {
public static int helper(int r, int c,int n, int m) {
if(r==0 && c==0)
return 2;
if(r==0 && c==m-1)
return 2;
if(r==n-1 && c==0)
return 2;
if(r==n-1 && c==m-1)
return 2;
if(r==0 || r==n-1 || c==0 || c==m-1)
return 3;
else
return 4;
}
public stat... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 53c7863681cc8405ccd84dc7107bb672 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;
public class Practice1 {
public static void main(String[] args) throws Exception {
FastInput in = new FastInput();
int t = in.nextInt();
... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | c2fb9c29034495a3e70238f7219388a3 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
// File file = new File("input.txt");
// Scanner in = new Scanner(file);
// PrintWriter out = new PrintWriter(new FileWriter("output.txt"));
public static void main(String[] args) {
// Scanner in = new Scanner(System.in);
... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | bf28c6b3e9dd0fcb776a2588b0bc62d8 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.util.*;
import java.io.*;
public class B {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0) {
int n = sc.nextInt();
int m = sc.nextInt();
int[][] a = new int[n][m];
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++)... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 427394830b5f38588a8403e58d8fd127 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.util.*;
public class bgr9{
public static void main(String args[]){
Scanner s = new Scanner(System.in);
int t = s.nextInt();
while(t-->0){
int n = s.nextInt();
int m = s.nextInt();
int arr[][] = new int[n][m];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
arr[i][j] = s.nextInt();
... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 835652b7a0908650ee13583a4e6594a7 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Problem problem = new Problem();
problem.solve();
}
}
class Problem {
private final Parser parser = new Parser();
void solve() {
int t = parser.parseInt();
for (int i =... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | e504ba3657fc6a4555a7a4c79e42ca91 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.util.*;
public class Problem1375b {
static int n,m;
static int[][] a;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
n = sc.nextInt();
m = sc.nextInt();
a = new int[... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 07ed1883d4839ce39f84e7273f26e4bc | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | //package test;
import java.io.*;
import java.util.*;
public class Grid {
static class FastReader
{
BufferedReader br;
public FastReader()
{
br = new BufferedReader(new InputStreamReader(System.in));
}
int nextInt() throws IOException
{
... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 22cf8840613eb3831efc8b4378ad09fb | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.util.*;
public class Main {
private static boolean go(int n, int m, int[][] p) {
if (p[0][0] > 2) return false;
if (p[n-1][0] > 2) return false;
if (p[0][m-1] > 2) return false;
if (p[n-1][m-1] > 2) return false;
for (int i = 0; i < n; ++i) {
if (p[i]... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 408140d88dcb560d4df8532c0059ff8d | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class code {
public static void main(String[] args)throws IOException {
FastReader sc = new FastReader();
PrintWriter pw = new PrintWriter(System.out);
int t = sc.ne... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | cc1c9b88915249daada5e605b1db077e | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes |
import java.util.*;
public class neighbor_grid {
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t>0){
t-=1;
int n=sc.nextInt(); int m=sc.nextInt();
int checker=0; int arr[][]=new int[n][m];
... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | a92c3e4aaa920e9df7497f9eb31a5968 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes |
//package cf;
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
public class gcd {
static int p=1000000007;
public static void main(String[] args) throws Exception{
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), "ASCI... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | f97ac66dada371b79f030bc2ac6147ac | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
FastReader f = new FastReader();
int t = f.nextInt();
while(t-- > 0) {
int n = f.nextInt();
int m = f.nextInt();
int[][] arr = new int[n][m];
... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 62fe9433e347adb414b123dcc2067604 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int test=0;test<t;test++)
{
int a=sc.nextInt();
int b=sc.nextI... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 2ebcd6689af4b275c3f0546437302437 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | /* package whatever; // don't place package name! */
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 Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
BufferedReader in... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | bfafa871d2a817c2b8c4b74468291bda | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | c394ce4231466bde6fa624969c0639b4 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.util.Scanner;
public class Main7 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while (t-->0)
{
int rows=sc.nextInt();
int col=sc.nextInt();
int arr[][]=new int[rows][col];
... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 1e4f56245f6958d5e53ad8aa0f1bcab7 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes |
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
public final class B {
public static void main(String[] args) {
final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
final int t = Integer.parseInt(in.nextLine());
... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | dd37d4267624a4d0ee94fa5665a4e3cf | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static Scanner sc = new Scanner(System.in);
static PrintWriter out = new PrintWriter(System.out);
public static void main(String[] args) throws Exception {
int t = sc.nextInt();
while(t-- > 0) {
int n = sc.nextInt(), m = sc.nextInt();
int arr[][] ... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | c9ae58f4d07696c38897d34cb011053c | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.util.*;
public class solution
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0)
{
int n=sc.nextInt();
int m=sc.nextInt();
int[][] a=new int[n][m];
for(int i=0;... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 931d3092b0428d37a85917127228b372 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
/* Name of the class has to be "Main" only if the class is public.
By : SSD
*/
public class NeibhourGrid {
static class FastReader {
BufferedReader br;
StringTokenizer st;
p... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 8406c6f933db89131e90ee6543cd92aa | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Template {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int test = sc.nextInt();
while(test-->0) {
int m = sc.nextInt();
int n = sc.nextInt();
int[][] a = new int[m][n];
for(int i=0 ; i<m ; i++) {
... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 6618e946be0cc30ba49b3e9715515bde | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Question2 {
static Reader sc = new Reader();
public static void main(String[] args) throws IOException{
int t = sc.nextInt();
while(t-->0) {
solve();
}
}
public static void solve() throws IOException{
int n = sc.nextInt();
int m = sc.nextInt();... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 5cf474b66f9b85ee438cd7b7ec86a60d | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Question2 {
static Reader sc = new Reader();
public static void main(String[] args) throws IOException{
int t = sc.nextInt();
while(t-->0) {
solve();
}
}
public static void solve() throws IOException{
int n = sc.nextInt();
int m = sc.nextInt();... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 27d8da8a4914a0d7594b87447e9f50a1 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Question2 {
static Reader sc = new Reader();
public static void main(String[] args) throws IOException{
int t = sc.nextInt();
while(t-->0) {
solve();
}
}
public static void solve() throws IOException{
int n = sc.nextInt();
int m = sc.nextInt();... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 3814b87a9ef32928e42e33248f637205 | train_003.jsonl | 1593873900 | You are given a grid with $$$n$$$ rows and $$$m$$$ columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number $$$k > 0$$$ written on it, then exactly $$$k$$$ of its neighboring cells have a number greater than $$$0$$$ ... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static Scanner sc = new Scanner(System.in);
static PrintWriter out = new PrintWriter(System.out);
/*
public static void main(String[] args) throws Exception {
int t = 1;
t = sc.nextInt();
while (t-- > 0) ... | Java | ["5\n3 4\n0 0 0 0\n0 1 0 0\n0 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n0 0 0\n0 4 0\n4 4\n0 0 0 0\n0 2 0 1\n0 0 0 0\n0 0 0 0"] | 1 second | ["YES\n0 0 0 0\n0 1 1 0\n0 0 0 0\nNO\nYES\n0 0\n0 0\nNO\nYES\n0 1 0 0\n1 4 2 1\n0 2 0 0\n1 3 1 0"] | NoteIn the first test case, we can obtain the resulting grid by increasing the number in row $$$2$$$, column $$$3$$$ once. Both of the cells that contain $$$1$$$ have exactly one neighbor that is greater than zero, so the grid is good. Many other solutions exist, such as the grid $$$$$$0\;1\;0\;0$$$$$$ $$$$$$0\;2\;1\;0... | Java 11 | standard input | [
"constructive algorithms",
"greedy"
] | 8afcdfaabba66fb9cefc5b6ceabac0d0 | The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) Β β the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \le n, m \le 300$$$) Β β the number of rows and columns, ... | 1,200 | If it is impossible to obtain a good grid, print a single line containing "NO". Otherwise, print a single line containing "YES", followed by $$$n$$$ lines each containing $$$m$$$ integers, which describe the final state of the grid. This final grid should be obtainable from the initial one by applying some operations (... | standard output | |
PASSED | 4b3a7fc5e8af69421f07fea03d0d8c6d | train_003.jsonl | 1349623800 | A piece of paper contains an array of n integers a1,βa2,β...,βan. Your task is to find a number that occurs the maximum number of times in this array.However, before looking for such number, you are allowed to perform not more than k following operations β choose an arbitrary element from the array and add 1 to it. In ... | 256 megabytes | // Main Code at the Bottom
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger;
public class Main {
//Fast IO class
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
boolean env=System.getProperty("ONLINE_JUD... | Java | ["5 3\n6 3 4 0 2", "3 4\n5 5 5", "5 3\n3 1 2 2 1"] | 2 seconds | ["3 4", "3 5", "4 2"] | NoteIn the first sample your task is to increase the second element of the array once and increase the fifth element of the array twice. Thus, we get sequence 6,β4,β4,β0,β4, where number 4 occurs 3 times.In the second sample you don't need to perform a single operation or increase each element by one. If we do nothing,... | Java 11 | standard input | [
"two pointers",
"binary search",
"sortings"
] | 3791d1a504b39eb2e72472bcfd9a7e22 | The first line contains two integers n and k (1ββ€βnββ€β105; 0ββ€βkββ€β109) β the number of elements in the array and the number of operations you are allowed to perform, correspondingly. The third line contains a sequence of n integers a1,βa2,β...,βan (|ai|ββ€β109) β the initial array. The numbers in the lines are separate... | 1,600 | In a single line print two numbers β the maximum number of occurrences of some number in the array after at most k allowed operations are performed, and the minimum number that reaches the given maximum. Separate the printed numbers by whitespaces. | standard output | |
PASSED | 363c7f08735e0e3b91a7e42d7ab5ddff | train_003.jsonl | 1349623800 | A piece of paper contains an array of n integers a1,βa2,β...,βan. Your task is to find a number that occurs the maximum number of times in this array.However, before looking for such number, you are allowed to perform not more than k following operations β choose an arbitrary element from the array and add 1 to it. In ... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
static int increment_to(long x, int idx, long k, long pref[]){
int l = 1, r = idx, res = 0, mid, cnt = 0;
long sum = 0l;
while(l <= r){
mid = l + (r - l)/2;
sum = pref[idx] - pref[mid - 1... | Java | ["5 3\n6 3 4 0 2", "3 4\n5 5 5", "5 3\n3 1 2 2 1"] | 2 seconds | ["3 4", "3 5", "4 2"] | NoteIn the first sample your task is to increase the second element of the array once and increase the fifth element of the array twice. Thus, we get sequence 6,β4,β4,β0,β4, where number 4 occurs 3 times.In the second sample you don't need to perform a single operation or increase each element by one. If we do nothing,... | Java 11 | standard input | [
"two pointers",
"binary search",
"sortings"
] | 3791d1a504b39eb2e72472bcfd9a7e22 | The first line contains two integers n and k (1ββ€βnββ€β105; 0ββ€βkββ€β109) β the number of elements in the array and the number of operations you are allowed to perform, correspondingly. The third line contains a sequence of n integers a1,βa2,β...,βan (|ai|ββ€β109) β the initial array. The numbers in the lines are separate... | 1,600 | In a single line print two numbers β the maximum number of occurrences of some number in the array after at most k allowed operations are performed, and the minimum number that reaches the given maximum. Separate the printed numbers by whitespaces. | standard output | |
PASSED | 32c0f92f7d775d6abf56c2b36c69031e | train_003.jsonl | 1349623800 | A piece of paper contains an array of n integers a1,βa2,β...,βan. Your task is to find a number that occurs the maximum number of times in this array.However, before looking for such number, you are allowed to perform not more than k following operations β choose an arbitrary element from the array and add 1 to it. In ... | 256 megabytes | import java.util.*;
import java.io.*;
public class AddOrNot{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = sc.nextInt();
int k = sc.nextInt();
int[] array = new int[n];
for(int i =0... | Java | ["5 3\n6 3 4 0 2", "3 4\n5 5 5", "5 3\n3 1 2 2 1"] | 2 seconds | ["3 4", "3 5", "4 2"] | NoteIn the first sample your task is to increase the second element of the array once and increase the fifth element of the array twice. Thus, we get sequence 6,β4,β4,β0,β4, where number 4 occurs 3 times.In the second sample you don't need to perform a single operation or increase each element by one. If we do nothing,... | Java 11 | standard input | [
"two pointers",
"binary search",
"sortings"
] | 3791d1a504b39eb2e72472bcfd9a7e22 | The first line contains two integers n and k (1ββ€βnββ€β105; 0ββ€βkββ€β109) β the number of elements in the array and the number of operations you are allowed to perform, correspondingly. The third line contains a sequence of n integers a1,βa2,β...,βan (|ai|ββ€β109) β the initial array. The numbers in the lines are separate... | 1,600 | In a single line print two numbers β the maximum number of occurrences of some number in the array after at most k allowed operations are performed, and the minimum number that reaches the given maximum. Separate the printed numbers by whitespaces. | standard output | |
PASSED | f308a5e87f78f18bed60c5f7b73c26ec | train_003.jsonl | 1349623800 | A piece of paper contains an array of n integers a1,βa2,β...,βan. Your task is to find a number that occurs the maximum number of times in this array.However, before looking for such number, you are allowed to perform not more than k following operations β choose an arbitrary element from the array and add 1 to it. In ... | 256 megabytes |
import java.util.*;
import java.io.*;
public class ToAddorNottoAdd {
// https://codeforces.com/contest/231/problem/C
public static void main(String[] args) throws IOException, FileNotFoundException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//BufferedReader in = new Buffered... | Java | ["5 3\n6 3 4 0 2", "3 4\n5 5 5", "5 3\n3 1 2 2 1"] | 2 seconds | ["3 4", "3 5", "4 2"] | NoteIn the first sample your task is to increase the second element of the array once and increase the fifth element of the array twice. Thus, we get sequence 6,β4,β4,β0,β4, where number 4 occurs 3 times.In the second sample you don't need to perform a single operation or increase each element by one. If we do nothing,... | Java 11 | standard input | [
"two pointers",
"binary search",
"sortings"
] | 3791d1a504b39eb2e72472bcfd9a7e22 | The first line contains two integers n and k (1ββ€βnββ€β105; 0ββ€βkββ€β109) β the number of elements in the array and the number of operations you are allowed to perform, correspondingly. The third line contains a sequence of n integers a1,βa2,β...,βan (|ai|ββ€β109) β the initial array. The numbers in the lines are separate... | 1,600 | In a single line print two numbers β the maximum number of occurrences of some number in the array after at most k allowed operations are performed, and the minimum number that reaches the given maximum. Separate the printed numbers by whitespaces. | standard output | |
PASSED | bcd60904dab59ae026a931720d9ff6a1 | train_003.jsonl | 1349623800 | A piece of paper contains an array of n integers a1,βa2,β...,βan. Your task is to find a number that occurs the maximum number of times in this array.However, before looking for such number, you are allowed to perform not more than k following operations β choose an arbitrary element from the array and add 1 to it. In ... | 256 megabytes |
import java.util.Arrays;
import java.util.Scanner;
public class Main {
static int arr[], dp[][], N, K, p;
static long pre[];
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n = input.nextInt();
K = input.nextInt();
arr = new int[n];
... | Java | ["5 3\n6 3 4 0 2", "3 4\n5 5 5", "5 3\n3 1 2 2 1"] | 2 seconds | ["3 4", "3 5", "4 2"] | NoteIn the first sample your task is to increase the second element of the array once and increase the fifth element of the array twice. Thus, we get sequence 6,β4,β4,β0,β4, where number 4 occurs 3 times.In the second sample you don't need to perform a single operation or increase each element by one. If we do nothing,... | Java 11 | standard input | [
"two pointers",
"binary search",
"sortings"
] | 3791d1a504b39eb2e72472bcfd9a7e22 | The first line contains two integers n and k (1ββ€βnββ€β105; 0ββ€βkββ€β109) β the number of elements in the array and the number of operations you are allowed to perform, correspondingly. The third line contains a sequence of n integers a1,βa2,β...,βan (|ai|ββ€β109) β the initial array. The numbers in the lines are separate... | 1,600 | In a single line print two numbers β the maximum number of occurrences of some number in the array after at most k allowed operations are performed, and the minimum number that reaches the given maximum. Separate the printed numbers by whitespaces. | standard output | |
PASSED | 3c57c7d27139231e4b77399fe3bfc480 | train_003.jsonl | 1349623800 | A piece of paper contains an array of n integers a1,βa2,β...,βan. Your task is to find a number that occurs the maximum number of times in this array.However, before looking for such number, you are allowed to perform not more than k following operations β choose an arbitrary element from the array and add 1 to it. In ... | 256 megabytes | import java.util.*;
import java.io.*;
public class Forces{
public static PrintWriter cout;
public static void main(String ...arg)
{
//Read cin = new Read();
InputReader cin = new InputReader(System.in);
cout = new PrintWriter(new BufferedOutputStream(System.out));
int n = cin.nextInt();
long k = cin.ne... | Java | ["5 3\n6 3 4 0 2", "3 4\n5 5 5", "5 3\n3 1 2 2 1"] | 2 seconds | ["3 4", "3 5", "4 2"] | NoteIn the first sample your task is to increase the second element of the array once and increase the fifth element of the array twice. Thus, we get sequence 6,β4,β4,β0,β4, where number 4 occurs 3 times.In the second sample you don't need to perform a single operation or increase each element by one. If we do nothing,... | Java 11 | standard input | [
"two pointers",
"binary search",
"sortings"
] | 3791d1a504b39eb2e72472bcfd9a7e22 | The first line contains two integers n and k (1ββ€βnββ€β105; 0ββ€βkββ€β109) β the number of elements in the array and the number of operations you are allowed to perform, correspondingly. The third line contains a sequence of n integers a1,βa2,β...,βan (|ai|ββ€β109) β the initial array. The numbers in the lines are separate... | 1,600 | In a single line print two numbers β the maximum number of occurrences of some number in the array after at most k allowed operations are performed, and the minimum number that reaches the given maximum. Separate the printed numbers by whitespaces. | standard output | |
PASSED | 643cc4f76b4a5202ed6b8e4aba011d9e | train_003.jsonl | 1349623800 | A piece of paper contains an array of n integers a1,βa2,β...,βan. Your task is to find a number that occurs the maximum number of times in this array.However, before looking for such number, you are allowed to perform not more than k following operations β choose an arbitrary element from the array and add 1 to it. In ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.Arrays;
public class Contest {
static PrintWriter out = new PrintWriter(System.out);
static f... | Java | ["5 3\n6 3 4 0 2", "3 4\n5 5 5", "5 3\n3 1 2 2 1"] | 2 seconds | ["3 4", "3 5", "4 2"] | NoteIn the first sample your task is to increase the second element of the array once and increase the fifth element of the array twice. Thus, we get sequence 6,β4,β4,β0,β4, where number 4 occurs 3 times.In the second sample you don't need to perform a single operation or increase each element by one. If we do nothing,... | Java 11 | standard input | [
"two pointers",
"binary search",
"sortings"
] | 3791d1a504b39eb2e72472bcfd9a7e22 | The first line contains two integers n and k (1ββ€βnββ€β105; 0ββ€βkββ€β109) β the number of elements in the array and the number of operations you are allowed to perform, correspondingly. The third line contains a sequence of n integers a1,βa2,β...,βan (|ai|ββ€β109) β the initial array. The numbers in the lines are separate... | 1,600 | In a single line print two numbers β the maximum number of occurrences of some number in the array after at most k allowed operations are performed, and the minimum number that reaches the given maximum. Separate the printed numbers by whitespaces. | standard output | |
PASSED | 0b5378d0e41737339afdd82b8c9e3a1f | train_003.jsonl | 1349623800 | A piece of paper contains an array of n integers a1,βa2,β...,βan. Your task is to find a number that occurs the maximum number of times in this array.However, before looking for such number, you are allowed to perform not more than k following operations β choose an arbitrary element from the array and add 1 to it. In ... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static... | Java | ["5 3\n6 3 4 0 2", "3 4\n5 5 5", "5 3\n3 1 2 2 1"] | 2 seconds | ["3 4", "3 5", "4 2"] | NoteIn the first sample your task is to increase the second element of the array once and increase the fifth element of the array twice. Thus, we get sequence 6,β4,β4,β0,β4, where number 4 occurs 3 times.In the second sample you don't need to perform a single operation or increase each element by one. If we do nothing,... | Java 11 | standard input | [
"two pointers",
"binary search",
"sortings"
] | 3791d1a504b39eb2e72472bcfd9a7e22 | The first line contains two integers n and k (1ββ€βnββ€β105; 0ββ€βkββ€β109) β the number of elements in the array and the number of operations you are allowed to perform, correspondingly. The third line contains a sequence of n integers a1,βa2,β...,βan (|ai|ββ€β109) β the initial array. The numbers in the lines are separate... | 1,600 | In a single line print two numbers β the maximum number of occurrences of some number in the array after at most k allowed operations are performed, and the minimum number that reaches the given maximum. Separate the printed numbers by whitespaces. | standard output | |
PASSED | 7760821ba24e583b41b55f92b4cc238f | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.util.Scanner;
public class CodeForces{
public static void main(String[] args){
Scanner s=new Scanner(System.in);
int n=s.nextInt();
int d=s.nextInt();
int e=5*s.nextInt();
int i=0,min=n;
while(n>=i*e) {
int rem=n-i*e;
rem-... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | 66f1fd221661d490a7bcbc87f0a08eba | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.util.*;
import java.lang.*;
import java.math.*;
import java.awt.image.ConvolveOp;
import java.io.*;
import java.text.DecimalFormat;
import java.lang.reflect.Array;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | 63898fac7fcfbef5f64ede5da2f58b2e | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.stream.IntStream;
public class Main {
public static void main(String args[]) {
InputReader in = new InputReader(System.in);
Pr... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | 5a61c56b928df96644c191dffe4fde6f | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.io.IOException;
import java.util.*;
public class contest {
public static void main(String []arg) throws IOException {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();int d=sc.nextInt();int e=sc.nextInt();int min=Integer.MAX_VALUE;
e=5*e;
for(int div=0;div*d<=n;div++) ... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | 02bc911182d07e1501f24c1a07baebf2 | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.io.IOException;
import java.util.*;
public class contest {
public static void main(String []arg) throws IOException {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();int d=sc.nextInt();int e=sc.nextInt();int min=Integer.MAX_VALUE;
for (int j = 0; j <= n / d; ... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | 67454091c4dd9d84ea708338f6f219fb | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.io.*;
import java.util.*;
public class Main {
private static int[][] st;
private static int [] logs;
public static void main(String[] args) throws IOException {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReade... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | dc2f71b8e6a6233174232b8ee2729390 | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int a,b,c,n,i,k,d,e,min;
a=s.nextInt();
b=s.nextInt();
c=s.nextInt();
c=5*c;
min=a;
for (d=0;d<=a;d+=b){
e=a-d;
... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | 261830a51fc14372be8ec4505d70a2cb | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.util.Scanner;
public class doors {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int d = s.nextInt();
int e = s.nextInt();
e*=5;
int ans = n;
for(int i = 0; i*d<=n; i++) {
ans = Math.min(ans, (n-i*d)%... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | ffb42f96becddd201a34708d34f308a7 | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
public class cf1214a {
static int[] weights;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// BufferedReader bu = new BufferedReader(new InputStreamReader(System.in));
Pr... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | 959b56a59a5d3b6ab160682f22cdc631 | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class Main {
void problem() {
int n = in.nextInt();
int d = in.nextInt();
int e = in.nextInt() * 5;
int ans = n;
for (int i = 0; i <= n; i += e) {
ans = min(ans, (n - i) % d);
... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | ab493bec7a0b8eff8485d1dd5bca9620 | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.util.Scanner;
public class Solution {
public static void main(String args[]) {
Scanner s=new Scanner(System.in);
int n=s.nextInt();
int d=s.nextInt();
int e=s.nextInt();
System.out.println(remainingRubles(n,d,e));
}
public static int remainingRubles(int n,... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | e52a6a8a3652d4d64f946b3953d732ad | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | //package main;
import java.io.*;
import java.util.*;
public final class Main {
Scanner sc;
public static void main(String[] args) throws Exception {
new Thread(null, new Main()::run, "main", 1 << 28).start();
}
{
sc = new Scanner(new BufferedReader(new InputStreamReader(System.i... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | a878927c51472805c991231afc24a518 | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.util.*;
import java.lang.*;
import java.math.*;
public class tc_5_1 {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int n=scn.nextInt();
int d=scn.nextInt();
int e=scn.nextInt();
int dn=0;
int de=0;
int ans=Integer.MAX_VALUE;
while((e*de)<=n) {
ans=Math... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | a7ec3575b943be28866630730b8fd8be | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.util.Scanner;
public class Codeforces {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int n=s.nextInt();
int dollar=s.nextInt();
int euro=5*s.nextInt();
int i=0;
int ans=Integer.MAX_VALUE;
while (i*dollar<=n){
ans=Math.min(ans,(n-(i*dolla... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | 850f941797ab802e329dc2576e9b1ddb | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.io.*;
import java.util.*;
public class ProblemA {
BufferedReader in;
PrintWriter out;
StringTokenizer ss;
String _token() throws IOException {
while (!ss.hasMoreTokens())
ss = new StringTokenizer(in.readLine());
return ss.nextToken();
}
int _int() throws IOException {
return Integer.parse... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | f2ae2d8144e5f58e934f95a19f8c2183 | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.io.*;
import java.util.*;
public class Laba {
FScanner fs;
PrintWriter pw;
int n, m;
boolean[] used;
int[][] dst;
long[] t;
HashMap<String, HashMap<String, Integer>> g;
HashSet<Character> goods = new HashSet<>();
public static void main(String[] args) throws IOException... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | b7eafe620116acc7b3c82d8ac125f4f7 | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner S=new Scanner(System.in);
int n=S.nextInt();
int d=S.ne... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | 5c90621d2dbf12312f47c26a3b57af88 | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class OptimalCurrencyExchange {
static class MyScanner {
private BufferedReader br;
private StringTokenizer st;
MyScanner() {
br = new BufferedR... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | 4271e936fef3d508cd4a1040f26c3e43 | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int n=sc.nextInt();
int d=sc.nextInt();
int e=sc.nextInt();
int r1,r2=n;
for(int i=0;i*5*e<=n;i++){
r1=(n-i*5*e)%(d);
if(r1<r2){
r2=r1;
}
}
System.out.p... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | 63df97f78b07474ce5a584c90025fd37 | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int n=sc.nextInt();
int d=sc.nextInt();
int e=sc.nextInt();
int r1,r2=n;
for(int i=0;i*d<=n;i++){
r1=(n-i*d)%(5*e);
if(r1<r2){
r2=r1;
}
}
System.out.pri... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | bd20aed8e8f1079ea4211f87d54d8b38 | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// write your code here
Scanner sc = new Scanner(System.in);
long n = sc.nextInt();
long d = sc.nextInt();
long e = sc.nextInt();
long nAns = n;
for (int i = 0; i < 100000... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | 456c4a878e1cb3e6b4fc9e45d67b1778 | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.io.*;
import java.util.*;
public class Program {
public static void main(String[] argv) throws IOException {
In cin = new In(new BufferedReader(new InputStreamReader(System.in)));
PrintWriter cout = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
int ... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | 1a571a4197a1d088ccf815894d3e1809 | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author Jenish
*/
public class Ma... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | a1110cf79e57ea90ed8ad27900510bb8 | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Random;
import java.io.PrintWriter;
/*
Solution Created: 16:44:52 11/09/2019
Custom Compet... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | b4a8266028b383aa48f2f31f34c7151b | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.io.*;
import java.util.*;
import java.lang.*;
import static java.lang.Math.*;
public class TaskC implements Runnable {
InputReader c;
PrintWriter w;
/*Global Variables*/
public void run() {
c = new InputReader(System.in);
w = new PrintWriter(System.out);
int n = c... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | b031a857fdfb962d6949c6e4cb3b083c | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Input... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | 8cbcbbc0da25a2182b02149a69246041 | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.util.*;
import java.io.*;
import java.math.*;
public class Es1
{
static IO io = new IO();
public static void main(String[] args)
{
int R = io.getInt();
int d = io.getInt();
int e = io.getInt();
int D = d;
int E = 5*e;
int mcm = (D*E);
int res = 1000000000;
int resto = R... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | eae1a9b18fd82c24ed1a51e0f33904c1 | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class Try
{
PrintWriter out;
Reader s;
private class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Reader() {
din = new DataInputStream... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | 7a3f61f4ae58b1dbfced7000c542827c | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
in... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | 4bbf7ed9f46dfd7025931645019034c9 | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | /******************************************************************************
Online Java Compiler.
Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.
*****************************************************... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | fc70aec8b5aeecc04847b562fb218656 | train_003.jsonl | 1567587900 | Andrew was very excited to participate in Olympiad of Metropolises. Days flew by quickly, and Andrew is already at the airport, ready to go home. He has $$$n$$$ rubles left, and would like to exchange them to euro and dollar bills. Andrew can mix dollar bills and euro bills in whatever way he wants. The price of one do... | 512 megabytes | import java.util.*;
public class Test{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int d=sc.nextInt();
int e=sc.nextInt();
int ans=n;
for (int i = 0; i * 5 * e <= n; ++i) {
ans = Math.min(ans... | Java | ["100\n60\n70", "410\n55\n70", "600\n60\n70"] | 1.5 seconds | ["40", "5", "0"] | NoteIn the first example, we can buy just $$$1$$$ dollar because there is no $$$1$$$ euro bill.In the second example, optimal exchange is to buy $$$5$$$ euro and $$$1$$$ dollar.In the third example, optimal exchange is to buy $$$10$$$ dollars in one bill. | Java 8 | standard input | [
"brute force",
"math"
] | 8c5d9b4fd297706fac3be83fc85028a0 | The first line of the input contains one integer $$$n$$$ ($$$1 \leq n \leq 10^8$$$)Β β the initial sum in rubles Andrew has. The second line of the input contains one integer $$$d$$$ ($$$30 \leq d \leq 100$$$)Β β the price of one dollar in rubles. The third line of the input contains integer $$$e$$$ ($$$30 \leq e \leq ... | 1,400 | Output one integerΒ β the minimum number of rubles Andrew can have after buying dollar and euro bills optimally. | standard output | |
PASSED | 8d1590c6fd29c5951c30565070641d29 | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class CodeForce209B {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringT... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | cafd258981c659cfabc60f59c80af869 | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes |
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Scanner;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author mark
*/
public class Permutation {
private static int... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | 42d71095004ded14c962ce9226c05f19 | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class Solution {
private IO io;
private int ioMode = -1;
private String problemName = "";
private final String mjArgument = "master_j";
public static void main(String programArguments[]) throws IOException{
if(pr... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | c6461e57655abb5d7e89a03f54a08eb7 | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes | import java.util.*;
public class Permutation {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int k = in.nextInt();
// start with sequence 1, 2, ..., 2*n, and invert first k pairs to obtain 2*k diff
StringBuilder sb = new StringBuilder();
for (int... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | 32ac6e4ad22ac90c43c1d446e0ceb242 | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes | import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class TaskB {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int n=in.nextInt();
int k=in.nextInt();
int[] a=new int[2*n];... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | 8d492932a0fd896d35fa98504afffc33 | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes | import java.util.*;
public class Main {
private static final long MOD = 1000000007;
public static void main(String[] args) throws Exception {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int k = scan.nextInt();
int[] arr = new int[2 * n];
... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | dac7ccafb09e88a0a8098bdc177aedea | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.text.*;
public class cf359b {
static BufferedReader br;
static Scanner sc;
static PrintWriter out;
public static void... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | 366558e8420ff0b279f4f5b2450a6a11 | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes | import java.util.Scanner;
public class Test {
public static void main(String[] args) {
permutation();
}
public static void permutation() {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
sc.close();
System.out.print((k + 1));
if(k!=0)
{
System.out.print(" "+1);
... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | 5d6465c6fd599d10719e8554976f2ddd | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes | import java.util.Scanner;
public class CodeForce {
public static void main(String[] args) {
try (Scanner sc = new Scanner(System.in)) {
int n=sc.nextInt();
int k=sc.nextInt();
if(k==0){
for(int i=1;i<=(2*n);i++){
if(i==(2... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | 5db3cd2b29e429e56be42343f888d743 | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes | import java.util.Scanner;
public class Main {
public static void main (String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int k = in.nextInt();
for (int i = 0; i < k; i++) {
System.out.print((2 * i + 2) + " " + (2 * i + 1) + " ");
}
for (int i = k; i < n; i++) {
System.out.p... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | b5d04d4df8a019586de5fc182d5259ab | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes | import static java.util.Arrays.deepToString;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;
public class Main {
static void solve() throws IOExceptio... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | dcfa493075df8f3e45f810e4b7102969 | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes | /*
Date :
Problem Name :
Location :
Algorithm :
Status :
Coding :
Thinking :
Time spent :
Note :
*/
import java.util.*;
import java.io.*;
public class Main {
static BufferedReader reader
= new BufferedReader(new InputStreamReader(... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | 0d8aa97c3d3d274538b2531a8d5ed508 | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
static BufferedReader reader
= new BufferedReader(new InputStreamReader(System.in));
static StringBuilder out = new StringBuilder();
public static void main(String[] args){
int n, k;
int[] inp = nextIntArray();
n = ... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | 4404461cc7440e345ae75e06ad5fca9a | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes | import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.StringTokenizer;
import java.io.InputStream;
/**
* Built using... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | 34be582e7c1d3e4e2423682697f278eb | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes | import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.HashSet;
import java.util.Random... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | 2feca5e3e13f0775142401daecc768eb | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes | import java.util.Scanner;
public class B {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
for(int i = 1; i <= n; i++){
if(k > 0){
System.out.print(2*i + " " + (2*i-1));
... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | 2a4d523a1762ebecfbdc440d4edda7db | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes | import java.io.PrintStream;
import java.util.*;
public class Problem209B {
public static void main(String[] args) throws Exception {
new Problem209B().solve(new Scanner(System.in), System.out);
}
public void solve(Scanner in, PrintStream out) throws Exception{
int n = in.nextInt();
... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | f0a41784cb1f7a3ee5d74c8768f17043 | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes | import java.util.Scanner;
public class Permutation {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
int n_swaps = n - k;
int swapped = 0;
for (int i = 1; i <= n; i++)... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | 723af62ef49f24f749861999d6967233 | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes |
import java.math.BigInteger;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;
import java.lang.Thread;
import java.lang.reflect.Array;
import java.util.Vector;
import java.math.*;
import javax.sound.sampled.Line;
public class Main {
public static void main(String[] args){
Scann... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | 0733c49e311b85dc9673ec561030cc9b | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes |
import java.util.Arrays;
import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int k = s.nextInt() * 2;
int[] arr = new int[n * 2];
for (int i = 0; i < n * 2; i++)
arr[i] =... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | 2057fae00fc6ad394fefe2d39c2e85e5 | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes | import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Stack;
public class Q1 {
public static void main(String[] args) {
FasterScanner s= new FasterScanner();
PrintWriter out=new PrintWrit... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | 18fdae8d5a23bcae568a21f4da634e17 | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes | import java.util.Scanner;
public class Problem_B_359 {
/**
* @param args
*/
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int[] a=new int[100001];
int n,m,i,j,l,k,w;
n=in.nextInt();
k=in.nextInt();
fo... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | 7a202c09cbbf8971e4baaea964a185bc | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes | import java.io.*;
import java.util.*;
public class cf359b {
static FastIO in = new FastIO(), out = in;
public static void main(String[] args) {
int n = in.nextInt(), k = in.nextInt();
int[] v = new int[2*n];
for(int i=0; i<2*n; i++)
v[i] = i+1;
for(int i=0; i<2*k; i+=2) {
int tmp = v[i... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output | |
PASSED | 8ceb7decae023a399c7b5b0f5587e238 | train_003.jsonl | 1383379200 | A permutation p is an ordered group of numbers p1,βββp2,βββ...,βββpn, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p1,βββp2,βββ...,βββpn.Simon has a positive integer n and a non-negative integer k, such that 2kββ€βn. Help him find permutation a of... | 256 megabytes | import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;
/**
*... | Java | ["1 0", "2 1", "4 0"] | 1 second | ["1 2", "3 2 1 4", "2 7 4 6 1 3 5 8"] | NoteRecord |x| represents the absolute value of number x. In the first sample |1β-β2|β-β|1β-β2|β=β0.In the second sample |3β-β2|β+β|1β-β4|β-β|3β-β2β+β1β-β4|β=β1β+β3β-β2β=β2.In the third sample |2β-β7|β+β|4β-β6|β+β|1β-β3|β+β|5β-β8|β-β|2β-β7β+β4β-β6β+β1β-β3β+β5β-β8|β=β12β-β12β=β0. | Java 7 | standard input | [
"dp",
"constructive algorithms",
"math"
] | 82de6d4c892f4140e72606386ec2ef59 | The first line contains two integers n and k (1ββ€βnββ€β50000, 0ββ€β2kββ€βn). | 1,400 | Print 2n integers a1,βa2,β...,βa2n β the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them. | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.