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 | 952d664bdfe3b90e7ca164e8f110a58a | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes |
import java.util.Scanner;
public class Yoo {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while(t-->0) {
int a = in.nextInt();
int b = in.nextInt();
if(a<4 && b<4 && a!=1 && b!=1) System.out.println("2 2");
else System.out.println("1 1");
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 6a84b304cbbfc8827d413ac589a4d319 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class CP {
static Scanner scan = new Scanner(System.in);
public static void solve()
{
int n,m;
n = scan.nextInt();
m = scan.nextInt();
if(n==1 || m==1)
{
System.out.println("1 1");
}
else{
System.out.println(n-1+" "+(m-1));
}
/* int Xarr[] = {-2,-2,-1,1,2,2,1,-1};
int Yarr[] = {1,-1,-2,-2,-1,1,2,2};
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
int c=0;
for(int k=0;k<8;k++)
{
int x = i+Xarr[k];
int y = j+Yarr[k];
if(x<=n && x>=1 && y<=m && y>=1) {
//System.out.println(x+" "+y);
c = 1;
continue;
}
}
if(c==0)
{
System.out.println(i+" "+j);
return;
//continue;
}
// if(c!=1)
// {
// System.out.println(i+" wef"+j);
// return;
// }
}
}
System.out.println(1+' '+1);
*/
}
public static void main(String[] args) {
Integer t = Integer.parseInt(scan.next());
//int t=1;
while(t>0) {
solve();
t--;
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | a2d369a9ccc26559d08cb9a4681060be | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class cp1 {
static void islocked(int i,int j){
if(i==1 || j==1 || (i<=3 && j<=3)){
if((i==3 || j==3)&& i!=1 && j!=1){System.out.println(2+" "+2);}
else {System.out.println(i+" "+j);}
}
else{
System.out.println(i+" "+j);
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t!=0){
int i = sc.nextInt();
int j = sc.nextInt();
islocked(i,j);
t--;
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 736cf1633f591bdf39aefb967ffe2a9c | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class A_Immobile_Knight{
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();
if((n==2 || n==3) && (m==2 || m==3))
{
System.out.println("2 2");
}
else
{
System.out.println("1 1");
}
}
sc.close();
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 57cdcf8338a36bb7058f53789d23bc06 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 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.
*******************************************************************************/
import java.util.*;
public class Main
{
public static boolean issorted(int []arr){
for(int i = 1;i<arr.length;i++){
if(arr[i]<arr[i-1]){
return false;
}
}
return true;
}
public static long sum(int []arr){
long sum = 0;
for(int i = 0;i<arr.length;i++){
sum+=arr[i];
}
return sum;
}
public static class pair implements Comparable<pair>{
int x;
int y;
pair(int x,int y){
this.x = x;
this.y = y;
}
public int compareTo(pair o){
return this.x - o.x; // sort increasingly on the basis of x
// return o.x - this.x // sort decreasingly on the basis of x
}
}
public static void swap(int []arr,int i,int j){
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
public static int gcd(int a, int b){
if (b == 0)
return a;
return gcd(b, a % b);
}
static int []parent = new int[1000];
static int []size = new int[1000];
public static void make(int v){
parent[v] = v;
size[v] = 1;
}
public static int find(int v){
if(parent[v]==v){
return v;
}
else{
return parent[v] = find(parent[v]);
}
}
public static void union(int a,int b){
a = find(a);
b = find(b);
if(a!=b){
if(size[a]>size[b]){
parent[b] = parent[a];
size[b]+=size[a];
}
else{
parent[a] = parent[b];
size[a]+=size[b];
}
}
}
static boolean []visited = new boolean[1000];
public static void dfs(int vertex,ArrayList<ArrayList<Integer>>graph){
if(visited[vertex] == true){
return;
}
System.out.println(vertex);
for(int child : graph.get(vertex)){
// work to be done before entering the child
dfs(child,graph);
// work to be done after exitting the child
}
}
public static void displayint(int []arr){
for(int i = 0;i<arr.length;i++){
System.out.print(arr[i]+" ");
}
System.out.println();
}
public static void displaystr(String str){
StringBuilder sb = new StringBuilder(str);
for(int i = 0;i<sb.length();i++){
System.out.print(sb.charAt(i));
}
System.out.println();
}
public static boolean checkbalanceparenthesis(StringBuilder ans){
Stack<Character>st = new Stack<>();
int i = 0;
while(i<ans.length()){
if(ans.charAt(i) == '('){
st.push('(');
}
else{
if(st.size() == 0 || st.peek()!='('){
return false;
}
else{
st.pop();
}
}
}
return st.size() == 0;
}
public static long binaryExp(long a,long b,long m){ /// This is Iterative Version
long res = 1;
while(b>0){
if((b&1)!=0){
res = (res*a)%m;
}
b>>=1;
a = (a*a)%m;
}
return res;
}
public static void query(int x,int y){
System.out.println("?"+" "+x+" "+y);
System.out.flush();
}
public static class SegmentTree{
int []tree;
int []arr;
SegmentTree(int []ar){
arr = ar;
tree = new int[4*arr.length];
build(1,0,arr.length-1);
}
private void build(int node,int start,int end){
if(start == end){
tree[node] = arr[start];
}
else{
int mid = start + (end-start)/2;
int left = 2*node;
int right = 2*node + 1;
build(left,start,mid);
build(right,mid+1,end);
tree[node] = Math.max(tree[left],tree[right]);
}
}
private int query(int node,int start,int end,int l,int r){
if(end<l || r<start){
return Integer.MIN_VALUE;
}
else if(l<=start && end<=r){
return tree[node];
}
else{
int mid = start + (end-start)/2;
int left = query(2*node,start,mid,l,r);
int right = query(2*node+1,mid+1,end,l,r);
return Math.max(left,right);
}
}
int query(int l,int r){
return query(1,0,arr.length-1,l,r);
}
void update(int node,int start,int end,int pos,int val){
if(start == end){
arr[start] = val;
tree[node] = val;
}
else{
int mid = start + (end-start)/2;
int left = 2*node;
int right = 2*node+1;
if(start<=pos && pos<=mid){
update(left,start,mid,pos,val);
}
else{
update(right,mid+1,end,pos,val);
}
tree[node] = Math.max(tree[left],tree[right]);
}
}
private void update(int pos,int val){
update(1,0,arr.length-1,pos,val);
}
}
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int t = scn.nextInt();
while(t-->0){
int n = scn.nextInt();
int m =scn.nextInt();
if((n == 3 && m == 2) || (n==2 && m == 3) || (n == 3 && m == 3)){
System.out.println(2+" "+2);
}
else{
System.out.println(1+" "+1);
}
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | a102d845b112f2a67a345c14b7c82444 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/**
* @author Nikolay Chistykov
*/
public class Main {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int t = sc.nextInt();
while (t-- > 0) {
int[] ints = new int[2];
fillArray(ints);
int n = ints[0];
int m = ints[1];
if (n == 3 && m == 3) {
System.out.println("2" + " " + "2");
} else if (n == 2 && m == 3){
System.out.println("2" + " " + "2");
} else if (n == 3 && m == 2 ) {
System.out.println("2" + " " + "2");
} else {
System.out.println(n + " " + m);
}
}
}
private static void fillArray(int[] ints) {
for (int i = 0; i < ints.length; i++) {
ints[i] = sc.nextInt();
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 96584a204f941b8a0499e77542d4060e | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class Solve {
static Scanner sc = new Scanner(System.in);
private static void solve() {
int n = sc.nextInt();
int m = sc.nextInt();
System.out.println((n + 1) / 2 + " " + (m + 1) / 2);
}
public static void main(String[] args) {
int tt = sc.nextInt();
while (tt-- > 0) {
solve();
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 68a923379bd81fbd9a0d7e4653cd1f71 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class a1739 {
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();
if((n>=2 && n<=3 )&&(m>=2 && m<=3)){
System.out.printf("%d%c%d%n",2,' ',2);
}
else{
System.out.printf("%d%c%d%n", 1,' ',1);
}
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 66dc159a733d6f9a82fdee22404cfc1c | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static int tcs, n, m;
static StringTokenizer st;
static void solved() throws IOException {
st = new StringTokenizer(br.readLine());
n = Integer.parseInt(st.nextToken());
m = Integer.parseInt(st.nextToken());
if(n <= 2 && m <= 2) {
System.out.println("1 1");
return;
}
if (n == 1) {
System.out.println("1 1");
return;
}
if (m == 1) {
System.out.println("1 1");
return;
}
if (n == 2 && m == 3) {
System.out.println("1 2");
return;
}
if (n == 3 && m == 2) {
System.out.println("2 1 ");
return;
}
if (n == 3 && m == 3) {
System.out.println("2 2");
return;
}
System.out.println("1 1 ");
}
public static void main(String[] args) throws IOException {
tcs = Integer.parseInt(br.readLine());
while (tcs-- > 0) {
solved();
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 511ca41237c1fcd9a4be7cbddd0c88e8 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
import java.lang.Math;
public class BeingZero2 {
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int t,n,m;
t=sc.nextInt();
while(t-->0)
{
n=sc.nextInt();
m=sc.nextInt();
if(n==1 || m==1)
{
System.out.println(n+" "+m);
}
else if(m==3 && n==3)
{
System.out.println("2 2");
}
else
{
n=n-1;
m=m-1;
System.out.println(n+" "+m);
}
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | c2b2c988f3a55c6d0d4d1e2b812bd18f | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class Abai {
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();
if(n==1 || m==1){
System.out.println(n+" "+m);
}else{
System.out.println((n/2+1)+" "+(m/2+1));
}
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | a48271d074e57ad41828c9749aeed9fb | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class problem {
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();
if (n == 1 || m == 1) System.out.println(n + " " + m);
else if (n == 2) {
if (m == 2) System.out.println("1 1");
else if (m == 3) System.out.println("1 2");
else System.out.println(n + " " + m);
} else if (m == 2) {
if (n == 2) System.out.println("1 1");
else if (n == 3) System.out.println("2 1");
else System.out.println(n + " " + m);
} else if (n == 3 && m == 3) System.out.println("2 2");
else System.out.println(n + " " + m);
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | cd32c9d831fdb50c17187b53919cc1dc | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class A {
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 min = Math.min(m, n);
int max = Math.max(m, n);
if(min <= 3 && max <= 3){
if(min == 1 && max >= 1){
System.out.println("1 1");
}else{
System.out.println("2 2");
}
}else{
System.out.println("1 1");
}
}
sc.close();
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | afe6083781573beb049620171cbebff7 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class Main {
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();
if((n==2 && m==2) || (n==3 && m==2) || (n==2 && m==3)||(n==3 && m==3))
System.out.println(2+" "+2);
else
System.out.println(n+" "+m);
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 9fc1f3f52a4f78f5eded33c6e4e95bdc | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes |
import java.io.*;
import java.util.*;
public class S1 {
public void solve(int a, int b, PrintWriter out) {
if (a == 1) {
out.println("1 1");
return;
}
if (b == 1) {
out.println("1 1");
return;
}
if (a * b > 9) {
out.println("1 1");
return;
}
out.println((1+a) / 2 + " " + (b+1)/ 2);
}
public static void main(String[] args) {
new S1().read();
}
static class FastScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
}
public void read() {
FastScanner fastScanner = new FastScanner();
PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
int N = fastScanner.nextInt();
while (N > 0) {
N--;
int a, b, n;
a = fastScanner.nextInt();
b = fastScanner.nextInt();
solve(a, b, out);
}
out.println();
out.close();
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 67ecf197af5d4bdf3a1d0d0b8940ac70 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static java.lang.System.*;
import static java.lang.System.out;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Arrays.sort;
import static java.util.Collections.shuffle;
import static java.util.Collections.sort;
public class Solution {
private final static FastScanner scanner = new FastScanner();
private final static int mod = (int) 1e9+7;
private final static int max_value = Integer.MAX_VALUE;
private final static int min_value = Integer.MIN_VALUE;
private static int[] a;
private static int n;
private static int m;
private static int t;
private final static String endl = "\n";
private static void solve() {
n = ii(); m = ii();
if ((n<3 && m<3) || (n == 1 || m == 1)) {
pl("1 1");
} else if (max(n, m) == 3) {
pl("2 2");
} else {
pl(n+" "+m);
}
}
public static void main(String[] args) {
t = ii();
while (t-->0) solve();
}
private static void swap(int[] a, int i, int j) {
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
private static void swap(int[] a, int[] b, int i) {
int temp = a[i];
a[i] = b[i];
b[i] = temp;
}
private static int f(int x) {
String a = x+"";
return a.length();
}
private static void iota(int[] a, int x) {
for (int i = 0; i<a.length; i++) a[i] = x++;
}
private static void reverse(int[] a) {
int[] b = new int[a.length];
int k = 0;
for (int i = a.length-1; i>=0; i--) {
b[k++] = a[i];
}
System.arraycopy(b, 0, a, 0, b.length);
}
private static long[] ral(int n) {
long[] a = new long[n];
for (int i = 0; i<n; i++) {
a[i] = ii();
}
return a;
}
private static int[] rai(int n) {
return scanner.readArray(n);
}
private static String[] ras(int n) {
return IntStream.range(0, n).mapToObj(i -> s()).toArray(String[]::new);
}
private static int lcm (int a, int b) {
return a / gcd (a, b) * b;
}
private static int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a % b);
}
private static int ii() {
return scanner.nextInt();
}
private static long l() {
return scanner.nextLong();
}
private static double d() {
return scanner.nextDouble();
}
private static String s() {
return scanner.next();
}
private static int toInt(String s) {
return Integer.parseInt(s);
}
private static ArrayList<Integer> list() {
return new ArrayList<>();
}
private static HashSet<Integer> set() {
return new HashSet<>();
}
private static HashMap<Integer, Integer> map() {
return new HashMap<>();
}
private static int toInt(char c) {
return Integer.parseInt(c+"");
}
private static<K> void pl(K a) {
p(a+endl);
}
private static<K> void p(K a) {
out.print(a);
}
private static void yes() {
pl("YES");
}
private static void no() {
pl("NO");
}
private static int max_a(int[] a) {
int max = a[0];
for (int j : a) {
if (j > max) {
max = j;
}
}
return max;
}
private static int min_a(int[] a) {
int min = a[0];
for (int j : a) {
if (j < min) {
min = j;
}
}
return min;
}
private static long sum(int[] a) {
return stream(a).asLongStream().sum();
}
private static void pl() {
out.println();
}
private static void printArray(long[] a) {
StringBuilder builder = new StringBuilder();
for (long i : a)
builder.append(i).append(' ');
pl(builder);
}
private static void printArray(int[] a) {
StringBuilder builder = new StringBuilder();
for (int i : a)
builder.append(i).append(' ');
pl(builder);
}
private static<K> void printArray(K[] a) {
StringBuilder builder = new StringBuilder();
for (K i : a)
builder.append(i).append(' ');
pl(builder);
}
private static int reverseInteger(int k) {
String a = k+"", res = "";
for (int i = a.length()-1; i>=0; i--) {
res+=a.charAt(i);
}
return toInt(res);
}
private static int phi(int n) {
int result = n;
for (int i=2; i*i<=n; i++)
if (n % i == 0) {
while (n % i == 0)
n /= i;
result -= result / i;
}
if (n > 1)
result -= result / n;
return result;
}
private static int pow(int a, int n) {
if (n == 0)
return 1;
if (n % 2 == 1)
return pow(a, n-1) * a;
else {
int b = pow (a, n/2);
return b * b;
}
}
private static boolean isPrimeLong(long n) {
BigInteger a = BigInteger.valueOf(n);
return a.isProbablePrime(10);
}
private static boolean isPrime(long n) {
return IntStream.iterate(2, i -> i * i <= n, i -> i + 1).noneMatch(i -> n % i == 0);
}
private static List<Integer> primes(int N) {
int[] lp = new int[N+1];
List<Integer> pr = new ArrayList<>();
for (int i=2; i<=N; ++i) {
if (lp[i] == 0) {
lp[i] = i;
pr.add(i);
}
for (int j = 0; j<pr.size() && pr.get(j)<=lp[i] && i*pr.get(j)<=N; ++j)
lp[i * pr.get(j)] = pr.get(j);
}
return pr;
}
private static Set<Integer> toSet(int[] a) {
return stream(a).boxed().collect(Collectors.toSet());
}
private static int linearSearch(int[] a, int key) {
return IntStream.range(0, a.length).filter(i -> a[i] == key).findFirst().orElse(-1);
}
private static<K> int linearSearch(K[] a, K key) {
return IntStream.range(0, a.length).filter(i -> a[i].equals(key)).findFirst().orElse(-1);
}
static int upper_bound(int[] arr, int key) {
int index = binarySearch(arr, key);
int n = arr.length;
if (index < 0) {
int upperBound = abs(index) - 1;
if (upperBound < n)
return upperBound;
else return -1;
}
else {
while (index < n) {
if (arr[index] == key)
index++;
else {
return index;
}
}
return -1;
}
}
static class FastScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(in));
StringTokenizer st = new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = nextInt();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
}
private static void stableSort(int[] a) {
List<Integer> list = stream(a).boxed().sorted().toList();
setAll(a, list::get);
}
private static void psort(int[] arr, int n) {
int min = min_a(arr);
int max = max_a(arr);
int range = max-min+1, i, j, index = 0;
int[] count = new int[range];
for(i = 0; i<n; i++)
count[arr[i] - min]++;
for(j = 0; j<range; j++)
while(count[j]-->0)
arr[index++]=j+min;
}
private static void csort(int[] a, int n) {
int max = max_a(a);
int min = min_a(a);
int range = max - min + 1;
int[] count = new int[range];
int[] output = new int[n];
for (int i = 0; i < n; i++) {
count[a[i] - min]++;
}
for (int i = 1; i < range; i++) {
count[i] += count[i - 1];
}
for (int i = n - 1; i >= 0; i--) {
output[count[a[i] - min] - 1] = a[i];
count[a[i] - min]--;
}
arraycopy(output, 0, a, 0, n);
}
private static void csort(char[] arr) {
int n = arr.length;
char[] output = new char[n];
int[] count = new int[256];
for (int i = 0; i < 256; ++i)
count[i] = 0;
for (char c : arr) ++count[c];
for (int i = 1; i <= 255; ++i)
count[i] += count[i - 1];
for (int i = n - 1; i >= 0; i--) {
output[count[arr[i]] - 1] = arr[i];
--count[arr[i]];
}
arraycopy(output, 0, arr, 0, n);
}
// Java Program to show segment tree operations like construction,
// query and update
static class SegmentTree
{
int[] st; // The array that stores segment tree nodes
/* Constructor to construct segment tree from given array. This
constructor allocates memory for segment tree and calls
constructSTUtil() to fill the allocated memory */
SegmentTree(int[] arr, int n)
{
// Allocate memory for segment tree
//Height of segment tree
int x = (int) (Math.ceil(Math.log(n) / Math.log(2)));
//Maximum size of segment tree
int max_size = 2 * (int) Math.pow(2, x) - 1;
st = new int[max_size]; // Memory allocation
constructSTUtil(arr, 0, n - 1, 0);
}
// A utility function to get the middle index from corner indexes.
int getMid(int s, int e) {
return s + (e - s) / 2;
}
/* A recursive function to get the sum of values in given range
of the array. The following are parameters for this function.
st --> Pointer to segment tree
si --> Index of current node in the segment tree. Initially
0 is passed as root is always at index 0
ss & se --> Starting and ending indexes of the segment represented
by current node, i.e., st[si]
qs & qe --> Starting and ending indexes of query range */
int getSumUtil(int ss, int se, int qs, int qe, int si)
{
// If segment of this node is a part of given range, then return
// the sum of the segment
if (qs <= ss && qe >= se)
return st[si];
// If segment of this node is outside the given range
if (se < qs || ss > qe)
return 0;
// If a part of this segment overlaps with the given range
int mid = getMid(ss, se);
return getSumUtil(ss, mid, qs, qe, 2 * si + 1) +
getSumUtil(mid + 1, se, qs, qe, 2 * si + 2);
}
/* A recursive function to update the nodes which have the given
index in their range. The following are parameters
st, si, ss and se are same as getSumUtil()
i --> index of the element to be updated. This index is in
input array.
diff --> Value to be added to all nodes which have i in range */
void updateValueUtil(int ss, int se, int i, int diff, int si)
{
// Base Case: If the input index lies outside the range of
// this segment
if (i < ss || i > se)
return;
// If the input index is in range of this node, then update the
// value of the node and its children
st[si] = st[si] + diff;
if (se != ss) {
int mid = getMid(ss, se);
updateValueUtil(ss, mid, i, diff, 2 * si + 1);
updateValueUtil(mid + 1, se, i, diff, 2 * si + 2);
}
}
// The function to update a value in input array and segment tree.
// It uses updateValueUtil() to update the value in segment tree
void updateValue(int arr[], int n, int i, int new_val)
{
// Check for erroneous input index
if (i < 0 || i > n - 1) {
System.out.println("Invalid Input");
return;
}
// Get the difference between new value and old value
int diff = new_val - arr[i];
// Update the value in array
arr[i] = new_val;
// Update the values of nodes in segment tree
updateValueUtil(0, n - 1, i, diff, 0);
}
// Return sum of elements in range from index qs (query start) to
// qe (query end). It mainly uses getSumUtil()
int getSum(int n, int qs, int qe)
{
// Check for erroneous input values
if (qs < 0 || qe > n - 1 || qs > qe) {
System.out.println("Invalid Input");
return -1;
}
return getSumUtil(0, n - 1, qs, qe, 0);
}
// A recursive function that constructs Segment Tree for array[ss..se].
// si is index of current node in segment tree st
int constructSTUtil(int arr[], int ss, int se, int si)
{
// If there is one element in array, store it in current node of
// segment tree and return
if (ss == se) {
st[si] = arr[ss];
return arr[ss];
}
// If there are more than one elements, then recur for left and
// right subtrees and store the sum of values in this node
int mid = getMid(ss, se);
st[si] = constructSTUtil(arr, ss, mid, si * 2 + 1) +
constructSTUtil(arr, mid + 1, se, si * 2 + 2);
return st[si];
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | dbdee3322bfbb5c5d3ae4107fcc39d6c | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | /**
* @author vivek
* <>
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class A {
private static void solveTC(int __) {
/* For Google */
// ans.append("Case #").append(__).append(": ");
//code start
int a= scn.nextInt();
int b= scn.nextInt();
if (a>1 && b>1)
print("2 2");
else{
print("1 1");
}
//code end
print("\n");
}
public static void main(String[] args) {
scn = new Scanner();
ans = new StringBuilder();
int t = scn.nextInt();
// int t = 1;
// int limit= ;
// sieve(limit);
/*
try {
System.setOut(new PrintStream(new File("file_i_o\\output.txt")));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
*/
for (int i = 1; i <= t; i++) {
solveTC(i);
}
System.out.print(ans);
}
//Stuff for prime start
/**
* sorting algos
*/
private static void sort(int[] arr) {
ArrayList<Integer> li = new ArrayList<>(arr.length);
for (int ele : arr) li.add(ele);
Collections.sort(li);
for (int i = 0; i < li.size(); i++) {
arr[i] = li.get(i);
}
}
private static void sort(long[] arr) {
ArrayList<Long> li = new ArrayList<>(arr.length);
for (long ele : arr) li.add(ele);
Collections.sort(li);
for (int i = 0; i < li.size(); i++) {
arr[i] = li.get(i);
}
}
private static void sort(float[] arr) {
ArrayList<Float> li = new ArrayList<>(arr.length);
for (float ele : arr) li.add(ele);
Collections.sort(li);
for (int i = 0; i < li.size(); i++) {
arr[i] = li.get(i);
}
}
private static void sort(double[] arr) {
ArrayList<Double> li = new ArrayList<>(arr.length);
for (double ele : arr) li.add(ele);
Collections.sort(li);
for (int i = 0; i < li.size(); i++) {
arr[i] = li.get(i);
}
}
/**
* List containing prime numbers <br>
* <b>i<sup>th</sup></b> position contains <b>i<sup>th</sup></b> prime number <br>
* 0th index is <b>null</b>
*/
private static ArrayList<Integer> listOfPrimes;
/**
* query <b>i<sup>th</sup></b> element to get if its prime of not
*/
private static boolean[] isPrime;
/**
* Performs Sieve of Erathosnesis and initialise isPrime array and listOfPrimes list
*
* @param limit the number till which sieve is to be performed
*/
private static void sieve(int limit) {
listOfPrimes = new ArrayList<>();
listOfPrimes.add(null);
boolean[] array = new boolean[limit + 1];
Arrays.fill(array, true);
array[0] = false;
array[1] = false;
for (int i = 2; i <= limit; i++) {
if (array[i]) {
for (long j = (long) i * i; j <= limit; j += i) {
array[(int) j] = false;
}
}
}
isPrime = array;
for (int i = 0; i <= limit; i++) {
if (array[i]) {
listOfPrimes.add(i);
}
}
}
//stuff for prime end
/**
* Calculates the Least Common Multiple of two numbers
*
* @param a First number
* @param b Second Number
* @return Least Common Multiple of <b>a</b> and <b>b</b>
*/
private static long lcm(long a, long b) {
return a * b / gcd(a, b);
}
/**
* Calculates the Greatest Common Divisor of two numbers
*
* @param a First number
* @param b Second Number
* @return Greatest Common Divisor of <b>a</b> and <b>b</b>
*/
private static long gcd(long a, long b) {
return (b == 0) ? a : gcd(b, a % b);
}
static void print(Object obj) {
ans.append(obj.toString());
}
static Scanner scn;
static StringBuilder ans;
//Fast Scanner
static class Scanner {
BufferedReader br;
StringTokenizer st;
public Scanner() {
br = new BufferedReader(new
InputStreamReader(System.in));
/*
try {
br = new BufferedReader(new
InputStreamReader(new FileInputStream(new File("file_i_o\\input.txt"))));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
*/
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
int[] nextIntArray(int n) {
int[] array = new int[n];
for (int i = 0; i < n; i++) {
array[i] = nextInt();
}
return array;
}
Integer[] nextIntegerArray(int n) {
Integer[] array = new Integer[n];
for (int i = 0; i < n; i++) {
array[i] = nextInt();
}
return array;
}
long[] nextLongArray(int n) {
long[] array = new long[n];
for (int i = 0; i < n; i++) {
array[i] = nextLong();
}
return array;
}
String[] nextStringArray() {
return nextLine().split(" ");
}
String[] nextStringArray(int n) {
String[] array = new String[n];
for (int i = 0; i < n; i++) {
array[i] = next();
}
return array;
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 2342ca1869616293fd0b60c5b2ca8e8f | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class solution
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
int t=in.nextInt();
{
while(t--!=0)
{
int row=in.nextInt();
int col=in.nextInt();
solve(row,col);
}
}
}
public static void solve(int row,int col)
{
if(row==3&&(col==3||col==2)||col==3&&(row==2||row==3))
{
System.out.println("2 2");
return;
}
System.out.println(row+" "+col);
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 62dfae86b774adca80b0fc69aee827ea | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | // Source: https://usaco.guide/general/io
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int t = sc.nextInt();
while(t-->0){
int r = sc.nextInt();
int c = sc.nextInt();
int ir = (r/2)+1;
int ic = (c/2)+1;
if(r>3 && c>3)
pw.println(1 + " " + 1);
else
pw.println(ir+ " "+ic);
}
/*
* Make sure to include the line below, as it
* flushes and closes the output stream
*/
pw.close();
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | df04ef3bc2a41683ec49060b59d4568e | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | // Source: https://usaco.guide/general/io
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int t = sc.nextInt();
while(t-->0){
int r = sc.nextInt();
int c = sc.nextInt();
int ir = (r/2)+1;
int ic = (c/2)+1;
if(r>3 && c>3)
pw.println(1 + " " + 1);
else
pw.println(ir+ " "+ic);
}
/*
* Make sure to include the line below, as it
* flushes and closes the output stream.
*/
pw.close();
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 29d885ce19111b1dd6e88e47e8a395cc | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class AInmobileKnight {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
try{
Thread.sleep(50);
}catch (InterruptedException e){}
int testcase = Integer.parseInt(s.nextLine());
// Review each one of the cases
for (int i = 0; i < testcase; i ++){
String[] numbers = s.nextLine().split(" ");
int rows = Integer.parseInt(numbers[0]);
int columns = Integer.parseInt(numbers[1]);
// Cases when all the cells are isolated
if (rows == 1 || columns == 1 || (rows == 2 && columns == 2)){
System.out.println(rows + " " + columns);
} else {
// Conditions for the while's to still running
boolean rown1 = true;
boolean rown2 = true;
// If the program hasn't print anything (Means that there are no isolated cells), it will print te position rows columns
boolean complete = false;
// To run throught the rows
int j = 1;
// It might go by every position on the board
while (rown1 && j <= rows){
// To run throught the columns
int x = 1;
while (rown2 && x <= columns) {
// if can't go in any direction (based on the knight movement) it means is an isolated cell and is a correct answer
if (!(j + 1 <= rows && x + 2 <= columns) &&
!(j+1 <= rows && 1 <= x-2) &&
!(j + 2 <= rows && x + 1 <= columns) &&
!(j + 2 <= rows && 1 <= x - 1) &&
!(1 <= j - 1 && x + 2 <= columns) &&
!(1 <= j - 1 && 1 <= x - 2) &&
!(1 <= j - 2 && 1 <= x - 1) &&
!(1 <= j - 2 && x + 1 <= columns)) {
rown1 = false;
rown2 = false;
// It is true bacause it prints one isolated cell
complete = true;
System.out.println(j + " " + x);
}
x++;
}
j++;
}
if (!complete){
System.out.println(rows + " " + columns);
}
}
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 0ec99b5b4b8d9ffbcf468380e2370a9e | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;
public class oooo {
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();
if(n-1!=0)
n--;
if(m-1!=0)
m--;
System.out.println(n+" "+m);
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 7fe2129dc44da19d84d537af1e9b4313 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class A1739 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
int n = 0,m = 0;
int[][] mas = new int[t][2];
for (int i = 0; i < t; i++) {
n = in.nextInt();
m = in.nextInt();
if (n*m >= 12) {
mas[i][0] = n;
mas[i][1] = m;
}
else if (n*m < 12 && n*m>=6 && n != 1 && m != 1){
mas[i][0] = 2;
mas[i][1] = 2;
}
else if (n*m < 6 || n == 1 || m == 1){
mas[i][0] = n;
mas[i][1] = m;
}
}
in.close();
for (int i = 0; i < t; i++) {
System.out.println(mas[i][0]+" "+mas[i][1]);
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | aa67ea57725b67d637376b1b96325b4c | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
public class A {
static int mod = (int) (1e9 + 7);
public static void main(String[] args) throws IOException {
// Scanner sc = new Scanner(new File("second_hands_input.txt"));
// PrintWriter pw = new PrintWriter("second_hands_output.txt");
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int t = sc.nextInt();
while (t-- > 0) {
int r = sc.nextInt();
int c = sc.nextInt();
int x = (r + 1) / 2;
int y = (c + 1) / 2;
pw.println(x + " " + y);
}
pw.flush();
}
static class pair implements Comparable<pair> {
int x, f;
char y;
public pair(int x, char y) {
this.x = x;
this.y = y;
}
@Override
public String toString() {
return x + " " + y;
}
@Override
public int compareTo(pair o) {
return y - o.y;
}
}
static long modPow(long a, long e, int mod) // O(log e)
{
a %= mod;
long res = 1;
while (e > 0) {
if ((e & 1) == 1)
res = (res * 1l * a) % mod;
a = (a * 1l * a) % mod;
e >>= 1;
}
return res;
}
static class Scanner {
StringTokenizer st;
BufferedReader br;
public Scanner(InputStream s) {
br = new BufferedReader(new InputStreamReader(s));
}
public Scanner(File s) throws FileNotFoundException {
br = new BufferedReader(new FileReader(s));
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public String nextLine() throws IOException {
return br.readLine();
}
public double nextDouble() throws IOException {
String x = next();
StringBuilder sb = new StringBuilder("0");
double res = 0, f = 1;
boolean dec = false, neg = false;
int start = 0;
if (x.charAt(0) == '-') {
neg = true;
start++;
}
for (int i = start; i < x.length(); i++)
if (x.charAt(i) == '.') {
res = Long.parseLong(sb.toString());
sb = new StringBuilder("0");
dec = true;
} else {
sb.append(x.charAt(i));
if (dec)
f *= 10;
}
res += Long.parseLong(sb.toString()) / f;
return res * (neg ? -1 : 1);
}
public boolean ready() throws IOException {
return br.ready();
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 87bc0b516cacae5f056e9ba2372117ee | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class Pset51 {
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();
if (Math.max(n, m) == 3) {
if (Math.min(n, m) == 1) {
System.out.println("1 1");
} else {
System.out.println("2 2");
}
} else {
System.out.println("1 1");
}
}
sc.close();
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | c7ac8cadcc4af21d3b81bafe67b778d8 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes |
import java.util.*;
import java.io.*;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.*;
import static java.lang.System.*;
public class CP0025 {
public static void main(String args[]) throws Exception {
PrintWriter pw = new PrintWriter(out);
FastReader sc = new FastReader();
Reader s = new Reader();
int test;
//code yaha se hai
try {
test = sc.nextInt();
} catch (Exception E) {
return;
}
while (test-- > 0) {
int n = sc.nextInt() ;
int m = sc.nextInt() ;
boolean pos = true ;
int ansi = 1 , ansj = 1 ;
for (int i = 1; i <= n ; i++) {
for (int j = 1; j <= m; j++) {
if(((i-1) > 0 && (j-2) > 0) || ((i-2) >0 && (j-1) > 0) || ((i-1) > 0 && (j+2) <= m) || ((i-2) < 0 && (j+1) <= m) || ((i+1) <= n && (j-2) > 0) || ((i+2) <= n && (j-1) > 0) || ((i+1) <= n && (j+2) <= m) || ((i+2) <= n && (j+1) <= m)){
}
else {
ansi = i ;
ansj = j ;
pos = false ;
break;
}
}
if(!pos){
break;
}
}
out.println(ansi + " " + ansj);
}
pw.close();
}
static long binSearch(long n){
long st = 1 , end = n ;
long mid , k , ans = 1 ;
while (st <= end){
mid = (end-st)/2 + st ;
k = (mid * (mid+1)) / 2 ;
if(n <= k){
if(n == k){
return mid ;
}
ans = mid ;
end = mid-1 ;
}
else {
st = mid+1 ;
}
}
return ans ;
}
public static int funcSort(int[] inputList)
{
int arr[] = new int[inputList.length +1 ] ;
arr[0] = 0 ;
for (int i = 0; i < inputList.length; i++) {
arr[i+1] = arr[i] + inputList[i] ;
}
for (int i = 0; i < arr.length; i++) {
out.println("ch " + arr[i]);
}
int minAns = Integer.MAX_VALUE ;
for (int i = 1; i < arr.length-1 ; i++) {
out.println( (arr[i] / i) + " " + ((arr[arr.length-1] -arr[i]) / (arr.length-i-1)) + " " + (arr[arr.length-1] -arr[i]) +" " + (arr.length-1-i) );
if(Math.abs( (arr[i] / i) - ((arr[arr.length-1] -arr[i]) / (arr.length-i-1)) ) < minAns){
minAns = Math.abs( (arr[i] / i) - ((arr[arr.length-1] -arr[i]) / (arr.length-i-1)) );
}
LinkedList<Integer> ls = new LinkedList<>();
}
return minAns ;
}
/*
Note :
Try using sorting , when approach is of O(N^2)
As sorting takes : O( N Log N )
*/
/*
len : Length of Array / inputs
num : key to map
//Putting values in map <Integer , ArrayList>
for (int i = 0; i < len; i++) {
num =sc.nextInt();
if(!mp.containsKey(num)){
mp.put(num ,new ArrayList<>());
}
}
//getting size of ArrayList
for(Integer key : mp.keySet()){
maxValue = max(maxValue , mp.get(key).size());
}
*/
/*
Sieve
boolean[] bool = new boolean[num];
for (int i = 0; i< bool.length; i++) {
bool[i] = true;
}
for (int i = 2; i< Math.sqrt(num); i++) {
if(bool[i] == true) {
for(int j = (i*i); j<num; j = j+i) {
bool[j] = false;
}
}
}
*/
static long exponentiation(long base, long exp)
{
long N = 1000000007 ;
if (exp == 0)
return 1;
if (exp == 1)
return base % N;
long t = exponentiation(base, exp / 2);
t = (t * t) % N;
// if exponent is even value
if (exp % 2 == 0)
return t;
// if exponent is odd value
else
return ((base % N) * t) % N;
}
public static int BinarySearch (long ar[] , int start , int end , long key , boolean lower){
int mid ;
boolean found = false;
int ans = 0;
if(lower){
while(start <= end){
mid = start + (end-start) / 2;
if(ar[mid] < key ){
if(!found){
ans = mid;
}
start = mid+1;
}
else{
if(ar[mid] == key){
found = true;
ans = mid ;
}
end = mid-1;
}
}
}
else{
while(start <= end){
mid = start + (end-start) / 2;
if(ar[mid] <= key ){
if(ar[mid] == key){
found = true;
ans = mid;
}
start = mid+1;
}
else{
if(!found){
ans = mid;
}
end = mid-1;
}
}
}
return ans;
}
public static int BinarySearchArrayList (ArrayList<Long> ar , int start , int end , long key , boolean lower){
int mid ;
boolean found = false;
int ans = -1;
if(lower){
while(start <= end){
mid = start + (end-start) / 2;
if(ar.get(mid) < key ){
if(!found){
ans = mid;
}
start = mid+1;
}
else{
if(ar.get(mid) == key){
found = true;
ans = mid ;
}
end = mid-1;
}
}
}
else{
while(start <= end){
mid = start + (end-start) / 2;
if(ar.get(mid) <= key ){
if(ar.get(mid) == key){
found = true;
ans = mid;
}
start = mid+1;
}
else{
if(!found){
ans = mid;
}
end = mid-1;
}
}
}
return ans;
}
public static String reverseString(String str){
StringBuilder input1 = new StringBuilder();
// append a string into StringBuilder input1
input1.append(str);
// reverse StringBuilder input1
input1.reverse();
return input1+"";
}
public static void sort(int[] arr){
//because Arrays.sort() uses quick sort , Worst Complexity : o(N^2)
ArrayList <Integer> ls = new ArrayList<>();
for(int x:arr){
ls.add(x);
}
Collections.sort(ls);
//Collections.sort(arrayList) : Uses Merge Sort : Complexity O(NlogN)
for(int i = 0 ; i < arr.length ; i++){
arr[i] = ls.get(i);
}
}
public static long gcd(long a , long b){
if(a>b){
a = (a+b) - (a = b);
}
if(a == 0L){
return b;
}
return gcd(b%a ,a);
}
public static boolean isPrime(long n){
if(n < 2){
return false;
}
if(n == 2 || n == 3){
return true;
}
if(n % 2 == 0 || n % 3 == 0){
return false;
}
long sq = (long)Math.sqrt(n) + 1;
for(long i = 5L; i <=sq ; i=i+6){
if(n % i == 0 || n % (i+2) == 0){
return false;
}
}
return true;
}
public static class Pair implements Comparable<Pair> {
long first ;
long second;
Pair(long fst , long scnd){
first = fst;
second = scnd;
}
public int compareTo(Pair obj){
if(this.first > obj.first){
return 1;
}
else if(this.first < obj.first){
return -1;
}
return 0;
}
}
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Reader()
{
din = new DataInputStream(System.in);
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public Reader(String file_name) throws IOException
{
din = new DataInputStream(
new FileInputStream(file_name));
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public String readLine() throws IOException
{
byte[] buf = new byte[64]; // line length
int cnt = 0, c;
while ((c = read()) != -1) {
if (c == '\n') {
if (cnt != 0) {
break;
}
else {
continue;
}
}
buf[cnt++] = (byte)c;
}
return new String(buf, 0, cnt);
}
public int nextInt() throws IOException
{
int ret = 0;
byte c = read();
while (c <= ' ') {
c = read();
}
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public long nextLong() throws IOException
{
long ret = 0;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public double nextDouble() throws IOException
{
double ret = 0, div = 1;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (c == '.') {
while ((c = read()) >= '0' && c <= '9') {
ret += (c - '0') / (div *= 10);
}
}
if (neg)
return -ret;
return ret;
}
private void fillBuffer() throws IOException
{
bytesRead = din.read(buffer, bufferPointer = 0,
BUFFER_SIZE);
if (bytesRead == -1)
buffer[0] = -1;
}
private byte read() throws IOException
{
if (bufferPointer == bytesRead)
fillBuffer();
return buffer[bufferPointer++];
}
public void close() throws IOException
{
if (din == null)
return;
din.close();
}
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while(st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch(IOException e){
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 2d0b37ccd6cdb48fa429fc91e5091954 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class immobileKnightCF{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while(t-- > 0){
int n = in.nextInt();
int m = in.nextInt();
if((n == 3 && m == 3) || (n == 2 && m == 3) || (n == 3 && m == 2))
System.out.println(2 + " " + 2);
else
System.out.println(n + " " + m);
}
in.close();
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 886a28ed8d6718a929c032635b86998f | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class immobileKnight{
public static void main(String[] args){
Scanner newScanner = new Scanner(System.in);
int testcases = newScanner.nextInt();
for(int i = 0; i<testcases; i++){
int rows = newScanner.nextInt();
int columns = newScanner.nextInt();
boolean squareFound = false;
for(int row = 1; row<=rows; row++)
{
for(int column = 1; column<=columns; column++)
{
if(!squareFound && (row+2>rows || column+1>columns) && (row+2>rows || column-1<=0) && (row-2<=0 || column+1>columns) && (row-2<=0 || column-1<=0) && (row+1>rows || column+2>columns) && (row+1>rows || column-2<=0) && (row-1<=0 || column+2>columns) && (row-1<=0 || column-2<=0))
{
System.out.println(row + " " + column);
squareFound = true;
}
}
}
if(!squareFound)
{
System.out.println("1 1");
}
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | d655cd2ed416681008093ae23a349190 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class Chess {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int test =sc.nextInt();
while (test > 0) {
int n = sc.nextInt();
int m = sc.nextInt();
int count = 0;
int p = 0;
int q = 0;
int r = -11;
int s = -11;
int a[][] = new int[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (ans(i, j,n,m) || ans1(i, j,n,m) || ans2(i, j,n,m) || ans3(i, j,n,m) || ans4(i, j,n,m) || ans5(i, j,n,m) || ans6(i, j,n,m) || ans7(i, j,n,m)) {
p = i;
q = j;
} else {
r = i;
s = j;
count++;
}
}
}
if (r != -11 && s != -11) {
System.out.println(r + 1 + " " + (s + 1));
}
if (count == 0) {
System.out.println(p + " " + q);
}
test--;
}
}
static boolean ans(int i,int j,int n,int m)
{
int vertical = i-2;
int col = j-1;
if(vertical<0 || col<0)
{
return false;
}
return true;
}
static boolean ans1(int i,int j,int n,int m)
{
int ver = i-2;
int col = j+1;
if(ver<0 || col>m-1)
{
return false;
}
return true;
}
static boolean ans2(int i,int j,int n,int m){
int ver = i-1;
int col = j+2;
if(ver<0 || col>m-1)
{
return false;
}
return true;
}
static boolean ans3(int i,int j,int n,int m)
{
int ver = i-1;
int col = j-2;
if(ver<0 || col<0)
{
return false;
}
return true;
}
static boolean ans4(int i,int j,int n,int m)
{
int ver = i+2;
int col = j+1;
if(ver>n-1 || col>m-1)
{
return false;
}
return true;
}
static boolean ans5(int i,int j,int n,int m)
{
int ver = i+2;
int col = j-1;
if(ver>n-1 || col <0)
{
return false;
}
return true;
}
static boolean ans6(int i,int j,int n,int m)
{
int ver=i+1;
int col=j-2;
if(ver>n-1 || col<0)
{
return false;
}
return true;
}
static boolean ans7(int i,int j,int n,int m)
{
int ver = i+1;
int col = j+2;
if(ver>n-1 || col>m-1)
{
return false;
}
return true;
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 42a8e8a3ecfb317ff5ce97c3f704eb4d | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner scn=new Scanner(System.in);
int t=scn.nextInt();
while(t-->0){
int n=scn.nextInt();
int m=scn.nextInt();
int f=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
int ar=i-2;
int ac=j-1;
int br=i-2;
int bc=j+1;
int cr=i+2;
int cc=j-1;
int dr=i+2;
int dc=j+1;
int er=i-1;
int ec=j-2;
int fr=i+1;
int fc=j-2;
int gr=i-1;
int gc=j+2;
int hr=i+1;
int hc=j+2;
if((ar>0&&ar<=n&&ac>0&&ac<=m)||(br>0&&br<=n&&bc>0&&bc<=m)||(cr>0&&cr<=n&&cc>0&&cc<=m)||(dr>0&&dr<=n&&dc>0&&dc<=m)||(er>0&&er<=n&&ec>0&&ec<=m)||(fr>0&&fr<=n&&fc>0&&fc<=m)||(gr>0&&gr<=n&&gc>0&&gc<=m)||(hr>0&&hr<=n&&hc>0&&hc<=m)){
continue;
}
System.out.print(i+" "+j);
f=1;
break;
}
if(f==1)break;
}
if(f==0)System.out.print(n+" "+m);
System.out.println();
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 8b7f520492ad1ebd3fc9f9dc39ba2757 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes |
import java.util.Scanner;
public class ac {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
for (int i = 0; i<a; i++){
int aa = sc.nextInt();
int bb = sc.nextInt();
if (aa==3 && bb==3){
System.out.println(2+" "+2);
}
else if (aa==2 && bb==3){
System.out.println(2+" "+2);
}
else if (aa==3 && bb==2){
System.out.println(2+" "+2);
}
else {
System.out.println(aa+" "+bb);
}
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 6b4c00e588066a7c6024dc5a74bb0c6e | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class Codeforce {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int t = input.nextInt();
for(int i=0;i<t;i++){
int n = input.nextInt();
int m = input.nextInt();
int nn = n%2==0?(n/2):((n+1)/2);
int mm = m%2==0?(m/2):((m+1)/2);
System.out.println(nn +" "+mm);
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 1725c0918a662f0e53a53e1b1f6f57f4 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.io.*;
import java.util.*;
public class A {
static InputReader in;
static OutputWriter out;
public static void main(String[] args) {
in = new InputReader(System.in);
out = new OutputWriter(System.out);
if (System.getProperty("ONLINE_JUDGE") == null) {
try {
in = new InputReader(new FileInputStream("input.txt"));
out = new OutputWriter(new FileOutputStream("output.txt"));
} catch (Exception e) {
}
}
int t = in.readInt();
for (int o = 1; o <= t; o++) {
int n, m, x;
n = in.readInt();
m = in.readInt();
solve(n, m);
}
out.flush();
out.close();
}
public static void solve(int n, int m) {
int x = n / 2 + (n % 2);
int y = m / 2 + (m % 2);
out.printLine(x + " " + y);
}
public static void print(int[] arr) {
for (int e : arr) {
out.print(e + " ");
}
out.printLine();
}
static class Point {
int x, y;
Point(int x, int y) {
this.x = x;
this.y = y;
}
}
}
class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private SpaceCharFilter filter;
public InputReader(InputStream stream) {
this.stream = stream;
}
public int read() {
if (numChars == -1)
throw new InputMismatchException();
if (curChar >= numChars) {
curChar = 0;
try {
numChars = stream.read(buf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (numChars <= 0)
return -1;
}
return buf[curChar++];
}
public int readInt() {
int c = read();
while (isSpaceChar(c))
c = read();
int sgn = 1;
if (c == '-') {
sgn = -1;
c = read();
}
int res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = read();
} while (!isSpaceChar(c));
return res * sgn;
}
public String readString() {
int c = read();
while (isSpaceChar(c))
c = read();
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = read();
} while (!isSpaceChar(c));
return res.toString();
}
public boolean isSpaceChar(int c) {
if (filter != null)
return filter.isSpaceChar(c);
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
public String next() {
return readString();
}
public interface SpaceCharFilter {
public boolean isSpaceChar(int ch);
}
}
class OutputWriter {
private final PrintWriter writer;
public OutputWriter(OutputStream outputStream) {
writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
}
public OutputWriter(Writer writer) {
this.writer = new PrintWriter(writer);
}
public void print(Object... objects) {
for (int i = 0; i < objects.length; i++) {
if (i != 0)
writer.print(' ');
writer.print(objects[i]);
}
}
public void printLine(Object... objects) {
print(objects);
writer.println();
}
public void close() {
writer.close();
}
public void flush() {
writer.flush();
}
}
class IOUtils {
public static int[] readIntArray(InputReader in, int size) {
int[] array = new int[size];
for (int i = 0; i < size; i++)
array[i] = in.readInt();
return array;
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 5827d89fb1c0d2c840abb4fa45c2a170 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | //My code is my Identity
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class prog4
{
/**
* @param args
*/
public static void main(String[] args) {
{
FastScanner sc = new FastScanner(System.in);
PrintWriter pr = new PrintWriter(System.out);
int t=sc.nextInt();
while(t-->0)
{
int n= sc.nextInt();
int k= sc.nextInt();
//int arr[]=new int[n];
// String st =sc.next();
// char c[]=st.toCharArray();
if((n==2&&k==3)||(n==3&&k==3)||(n==3&&k==2))
pr.println("2 2");
else
pr.println("1 1");
}
pr.close();
}
}
static int smallestDivisor(int n)
{
// if divisible by 2
if (n % 2 == 0)
return 2;
// iterate from 3 to sqrt(n)
for (int i = 3; i * i <= n; i += 2) {
if (n % i == 0)
return i;
}
return n;
}
}
class FastScanner
{
private BufferedReader reader = null;
private StringTokenizer tokenizer = null;
public FastScanner(InputStream in)
{
reader = new BufferedReader(new InputStreamReader(in));
tokenizer = null;
}
public String next()
{
if (tokenizer == null || !tokenizer.hasMoreTokens())
{
try
{
tokenizer = new StringTokenizer(reader.readLine());
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public String nextLine()
{
if (tokenizer == null || !tokenizer.hasMoreTokens())
{
try
{
return reader.readLine();
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
return tokenizer.nextToken(
);
}
public long nextLong()
{
return Long.parseLong(next());
}
public int nextInt()
{
return Integer.parseInt(next());
}
public double nextDouble()
{
return Double.parseDouble(next());
}
public int[] nextIntArray(int n)
{
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
public long[] nextLongArray(int n)
{
long[] a = new long[n];
for (int i = 0; i < n; i++)
a[i] = nextLong();
return a;
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | c40e56905443f27e6fd68686ac249423 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.io.*;
import java.util.*;
public class A {
final static boolean multipleTests = true;
Input in;
PrintWriter out;
public A() {
in = new Input(System.in);
out = new PrintWriter(System.out);
}
public static void main(String[] args) {
A solution = new A();
int t = 1;
if (multipleTests) t = solution.in.nextInt();
for (; t > 0; t--) {
solution.solve();
}
solution.out.close();
}
void solve() {
int n = in.nextInt();
int m = in.nextInt();
if (n == 3 && m == 3) {
out.println("2 2");
} else if (n == 2 && m == 3) {
out.println("1 2");
} else if (n == 3 && m == 2) {
out.println("2 1");
} else {
out.println("1 1");
}
}
static class Input {
BufferedReader br;
StringTokenizer st;
public Input(InputStream in) {
br = new BufferedReader(new InputStreamReader(in));
st = new StringTokenizer("");
}
String nextString() {
while (!st.hasMoreTokens()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(nextString());
}
long nextLong() {
return Long.parseLong(nextString());
}
double nextDouble() {
return Double.parseDouble(nextString());
}
int[] nextIntArray(int size) {
int[] ans = new int[size];
for (int i = 0; i < size; i++) {
ans[i] = nextInt();
}
return ans;
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | a76771561c357feb474bd1a3c560d4e2 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
import java.io.*;
public class Solution extends Helper {
private static SuperFastReader sc = new SuperFastReader();
// private static final FastReader sc = new FastReader();
// private static final Scanner sc = new Scanner(System.in);
private static PrintWriter out = new PrintWriter(System.out);
// static {
// try {
// sc = new SuperFastReader("input.txt");
// out = new PrintWriter("output.txt");
// } catch (Exception e) {
// debug(e);
// }
// }
static int moves[][] = {
{-1,-2},{-2,-1},{-2,1},{-1,2},
{1,2},{2,1},{2,-1},{1,-2}
};
public static void main(String[] args) throws IOException {
int t = sc.Int();
for (int i = 1; i <= t; ++i) {
// System.out.print("Case #" + i + ": ");
solve();
}
// solve();
sc.close();
out.close();
}
public static void solve() throws IOException {
int n = sc.Int();
int m = sc.Int();
for(int i = 0;i < n;i++){
for(int j = 0;j < m;j++){
boolean sts = true;
for(var mov:moves){
int x = i + mov[0];
int y = j + mov[1];
if(x >= 0 && x < n && y >= 0 && y < m){
sts = false;
break;
}
}
if(sts){
println((i + 1) + " " + (j + 1));
return;
}
}
}
println(1 + " " + 1);
}
public static <T> void debug(T data) {
System.out.println(data);
}
public static <T> void print(T data) {
out.print(data);
}
public static <T> void println(T data) {
out.println(data);
}
public static void println() {
out.println();
}
public static void read(int arr[]) throws IOException {
for (int i = 0; i < arr.length; i++) {
arr[i] = sc.Int();
}
}
public static void read(long arr[]) throws IOException {
for (int i = 0; i < arr.length; i++) {
arr[i] = sc.Long();
}
}
public static void read(String arr[]) throws IOException {
for (int i = 0; i < arr.length; i++) {
arr[i] = sc.next();
}
}
public static void read(int mat[][]) throws IOException {
for (int i = 0; i < mat.length; i++) {
for (int j = 0; j < mat[i].length; j++) {
mat[i][j] = sc.Int();
}
}
}
public static void read(long mat[][]) throws IOException {
for (int i = 0; i < mat.length; i++) {
for (int j = 0; j < mat[i].length; j++) {
mat[i][j] = sc.Long();
}
}
}
}
class DSU {
public int par[];
private long size[];
public DSU(int n) {
par = new int[n];
size = new long[n];
for (int i = 0; i < n; i++) {
par[i] = i;
size[i] = 1;
}
}
public int get(int c) {
if (c == par[c])
return c;
return par[c] = get(par[c]);
}
public void union(int x, int y) {
x = get(x);
y = get(y);
if (x != y) {
if (size[x] < size[y]) {
int t = x;
x = y;
y = t;
}
par[y] = x;
size[x] += size[y];
}
}
}
class Pair<K, V> {
public K key;
public V value;
Pair(K k, V v) {
key = k;
value = v;
}
}
class SuperFastReader {
private InputStream stream;
private byte[] buf = new byte[1 << 16];
private int curChar, numChars;
// standard input
public SuperFastReader() {
stream = System.in;
}
// file input
public SuperFastReader(String file) throws IOException {
stream = new FileInputStream(file);
}
private int nextByte() {
if (numChars == -1)
throw new InputMismatchException();
if (curChar >= numChars) {
curChar = 0;
try {
numChars = stream.read(buf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (numChars == -1)
return -1; // end of file
}
return buf[curChar++];
}
public String next() {
int c;
do {
c = nextByte();
} while (c <= ' ');
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = nextByte();
} while (c > ' ');
return res.toString();
}
public String nextLine() {
int c;
do {
c = nextByte();
} while (c < '\n');
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = nextByte();
} while (c > '\n');
return res.toString().trim(); // .trim() used to remove '\n' from either ends
}
public int Int() {
int c;
do {
c = nextByte();
} while (c <= ' ');
int sgn = 1;
if (c == '-') {
sgn = -1;
c = nextByte();
}
int res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res = 10 * res + c - '0';
c = nextByte();
} while (c > ' ');
return res * sgn;
}
public long Long() {
int c;
do {
c = nextByte();
} while (c <= ' ');
int sgn = 1;
if (c == '-') {
sgn = -1;
c = nextByte();
}
long res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res = 10 * res + c - '0';
c = nextByte();
} while (c > ' ');
return res * sgn;
}
public double Double() {
return Double.parseDouble(next());
}
public char Char() {
return next().charAt(0);
}
public void close() throws IOException {
stream.close();
}
}
class Helper {
public static final int MOD = (int) (1e9) + 7;// ((a + b) % MOD + MOD) % MOD
public static long powMod(long base, long exp) {
long ans = 1;
for (; exp != 0;) {
if ((exp & 1) == 1) {
ans *= base;
ans %= MOD;
}
base *= base;
base %= MOD;
exp = exp >> 1;
}
return ans;
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 6118d6f049a372294ef093647226593f | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | //https://codeforces.com/contest/1739/problem/0
import java.util.*;
public class Immobile_Knight_1739A {
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();
if(n == 3 && m == 3)
System.out.println("2 2");
else if(n == 2 && m == 3)
System.out.println("1 2");
else if(n==3 && m == 2)
System.out.println("2 1");
else {
System.out.println(n + " " + m);
}
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 3329f3e86f2fde1e2d1d2b6de709b070 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class code {
/**
* @param args
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
// List<Integer> arrx=new ArrayList<>();
// List<Integer> arrt=new ArrayList<>();
// List<Integer> arrb=new ArrayList<>();
// Set<Integer> s1=new HashSet<>();
// Set<Integer> s2=new HashSet<>();
// Vector<Integer> v = new Vector<>();
// Map<Integer,Integer> m1=new HashMap<>();
// Map<Integer,Integer> m2=new HashMap<>();
// Integer[] a = new Integer[20009];
// Integer[] b=new Integer[20009];
// Map<Integer,Integer> mp=new HashMap<>();
while(t>0){
// System.out.print("Case #"+i+": ");
int n=sc.nextInt();
int m=sc.nextInt();
n=n/2 + n%2;
m=m/2 + m%2;
System.out.println(n+" "+m);
t--;
}
sc.close();
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 3407bd9038eefde3988017f5917acc69 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class CF_1736A_ImmobileKnight {
public static void f(int n,int m)
{
if(n<=2&&m<=2)
{
System.out.println(1+" "+1);
return;
}
else if((n==3&&m==2)||(m==3&&n==2)||(m==3&&n==3)){
System.out.println(2+" "+2);
return;
}else {
System.out.println(1+" "+1);
}
}
public static void main(String[] args) {
// TODO 自动生成的方法存根
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t>0) {
int n=sc.nextInt();
int m=sc.nextInt();
f(n, m);
t--;
}
sc.close();
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 1cea4c650df450284203078ac059daee | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.io.*;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.*;
import static java.lang.Math.*;
public class NewProgramJava {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
if (st.hasMoreTokens()) {
str = st.nextToken("\n");
} else {
str = br.readLine();
}
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
static void printArr(int[] arr) {
for (int j : arr) {
System.out.print(j + " ");
}
System.out.println();
}
static void printArrList(ArrayList<Integer> arr) {
for (int j : arr) {
System.out.print(j + " ");
}
System.out.println();
}
static class Pair {
int first;
int second;
Pair(int first, int second) {
this.first = first;
this.second = second;
}
}
static class Trio {
String first;
int second;
int third;
Trio(String first, int second, int third) {
this.first = first;
this.second = second;
this.third = third;
}
}
static class sortPairBySecond implements Comparator<Pair> {
@Override
public int compare(Pair o1, Pair o2) {
return o1.second - o2.second;
}
}
static class sortPairByFirst implements Comparator<Pair> {
@Override
public int compare(Pair o1, Pair o2) {
return o1.first - o2.first;
}
}
static class sortTrioByFirst implements Comparator<Trio> {
@Override
public int compare(Trio o1, Trio o2) {
if (o1.first.compareTo(o2.first) == 0){
return o1.third - o2.third;
}
else return o1.first.compareTo(o2.first);
}
}
static class sortTrioBySecond implements Comparator<Trio> {
@Override
public int compare(Trio o1, Trio o2) {
if (o1.second == o2.second){
return o1.third - o2.third;
}
else return o1.second - o2.second;
}
}
static class sortTrioByThird implements Comparator<Trio> {
@Override
public int compare(Trio o1, Trio o2) {
return o1.third - o2.third;
}
}
static long exponentMod(long A,
long B, long C)
{
// Base cases
if (A == 0)
return 0;
if (B == 0)
return 1;
// If B is even
long y;
if (B % 2 == 0)
{
y = exponentMod(A, B / 2, C);
y = (y * y) % C;
}
// If B is odd
else
{
y = A % C;
y = (y * exponentMod(A, B - 1,
C) % C) % C;
}
return ((y + C) % C);
}
static long nCr(long n, long r)
{
return fact(n) / (fact(r) *
fact(n - r));
}
static long fact(long n)
{
if(n==0)
return 1L;
long res = 1L;
for (long i = 2L; i <= n; i++)
res = res * i;
return res;
}
static class Graph
{
int V;
Vector<Integer>[] adj;
@SuppressWarnings("unchecked")
Graph(int V)
{
adj = new Vector[V];
for (int i = 0; i < adj.length; i++)
{
adj[i] = new Vector<>();
}
this.V = V;
}
void addEdge(int v, int w)
{
adj[v].add(w);
adj[w].add(v);
}
int BFS(int s, int l)
{
boolean[] visited = new boolean[V];
int[] level = new int[V];
for (int i = 0; i < V; i++)
{
visited[i] = false;
level[i] = 0;
}
Queue<Integer> queue = new LinkedList<>();
visited[s] = true;
queue.add(s);
level[s] = 0;
int count = 0;
while (!queue.isEmpty())
{
s = queue.peek();
queue.poll();
Vector<Integer> list = adj[s];
for (int i : list)
{
if (!visited[i])
{
visited[i] = true;
level[i] = level[s] + 1;
queue.add(i);
}
}
count = 0;
for (int i = 0; i < V; i++)
if (level[i] == l)
count++;
}
return count;
}
}
public static void main(String[] args) throws Exception {
FastReader sc = new FastReader();
int T = sc.nextInt();
while (T>0){
T--;
int n = sc.nextInt();
int m = sc.nextInt();
if (m == 1 || n == 1){
System.out.println(1 + " " + 1);
}
else {
System.out.println(2 + " " + 2);
}
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 319654b5d5a43c961f5c71870a031568 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | // 09/11/2022
import java.util.*;
public class A1739 {
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();
System.out.println((n + 1) / 2 + " " + (m + 1) / 2);
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | e1782f159e465e1537f62f5f78dbfbbe | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class Knight
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int cases = new Integer(scan.nextLine());
for (int i = 0; i < cases; i++)
{
String[] tokens = scan.nextLine().split(" ");
int rows = new Integer(tokens[0]);
int cols = new Integer(tokens[1]);
System.out.println((rows/2+1) + " " + (cols/2+1));
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 8801fc7a1820758bcbb8148d5bc21aa7 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class immobileknight {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int nbofcases = input.nextInt();
for (int q = 0; q < nbofcases; q++) {
int clmns = input.nextInt();
int rows = input.nextInt();
if (clmns > 3 && rows > 3) {
System.out.println(clmns + " " + rows);
} else {
System.out.println((clmns + 1) / 2 + " " + (rows + 1) / 2);
}
}
input.close();
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 9987ea914f5a7f0fd68b738fd2728dd7 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.io.*;
import java.util.StringTokenizer;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
Scanner scan = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int t = scan.nextInt();
while (t-- > 0)
{
int n = scan.nextInt();
int m = scan.nextInt();
// when both numbers are greater than 3, nothing isolated
if (n <= 3 || m <= 3)
{
int ni = (1+n)/2;
int mi = (1+m)/2;
String isolated = ni + " " + mi;
pw.println(isolated);
}
else
{
pw.println(n + " " + m);
}
}
/*
* Make sure to include the line below, as it
* flushes and closes the output stream.
*/
pw.close();
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | e9cc5e66ae3907777c964b89ba0681c2 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class Solve {
static Scanner sc = new Scanner(System.in);
private static void solve() {
int n = sc.nextInt();
int m = sc.nextInt();
System.out.println((n + 1) / 2 + " " + (m + 1) / 2);
}
public static void main(String[] args) {
int tt = sc.nextInt();
while (tt-- > 0) {
solve();
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | d68e771ce6dfd72376de6fd7eeb23d8c | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
import static java.lang.Math.min;
public class Main {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int t=in.nextInt();
while (t>0){
int a,b;
a=in.nextInt();
b=in.nextInt();
int mini=min(a,b);
if(a==3&&b==3)
{
System.out.println("2 2\n");
}
else if(a==1||b==1)
{
System.out.println(a+" "+b+"\n");
}
else if(mini==2)
{
System.out.println("2 2\n");
}
else {
System.out.println("2 2\n");
}
t--;
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | c6686b3f08bedda72db753959ee194ae | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
import static java.lang.Math.min;
public class Main {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int t=in.nextInt();
while (t>0){
int a,b;
a=in.nextInt();
b=in.nextInt();
int mini=min(a,b);
if(a==3&&b==3)
{
System.out.println("2 2\n");
}
else if(a==1||b==1)
{
System.out.println(a+" "+b+"\n");
}
else if(mini==2)
{
System.out.println("2 2\n");
}
else {
System.out.println("2 2\n");
}
t--;
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | cdbd4ea2913b2acee4fa70bbf87b235f | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class here_we_go {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int t = scnr.nextInt();
while (t > 0) {
t--;
int n, m;
n = scnr.nextInt();
m = scnr.nextInt();
System.out.print(n/2+1);
System.out.print(" ");
System.out.println(m/2+1);
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 2c4f5f64027a1687313cb088c1ba8fdb | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.io.*;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException{
new Main().run();
}
void run()throws IOException{
new Solve().setIO(System.in,System.out).run();
}
public class Solve extends IOTask{
int t,n,m,x,y;
public void run()throws IOException{
t=in.in();
while(t-->0){
n=in.in();
m=in.in();
x=1;y=1;
if(n==3)x=2;
if(m==3)y=2;
out.println(x+" "+y);
}
out.close();
}
}
class In{
private StringTokenizer in;
private BufferedReader br;
private InputStream is;
private void init(){
br=new BufferedReader(new InputStreamReader(is));
in=new StringTokenizer("");
}
public In(InputStream is){
this.is=is;
init();
}
public In(File file)throws IOException {
is=new FileInputStream(file);
init();
}
public String ins()throws IOException{
while(!in.hasMoreTokens())in=new StringTokenizer(br.readLine());
return in.nextToken();
}
public int in()throws IOException{
return Integer.parseInt(ins());
}
public long inl()throws IOException{
return Long.parseLong(ins());
}
public double ind()throws IOException{
return Double.parseDouble(ins());
}
}
class Out{
public PrintWriter out;
OutputStream os;
private void init(){
out=new PrintWriter(new BufferedWriter(new OutputStreamWriter(os)));
}
public Out(OutputStream os){
this.os=os;
init();
}
public Out(File file)throws IOException{
this.os=new FileOutputStream(file);
init();
}
}
abstract class IOTask{
In in;
PrintWriter out;
public IOTask setIO(InputStream is,OutputStream os)throws IOException{
in=new In(is);
out=new Out(os).out;
return this;
}
public IOTask setIO(File is,OutputStream os)throws IOException{
in=new In(is);
out=new Out(os).out;
return this;
}
public IOTask setIO(InputStream is,File os)throws IOException{
in=new In(is);
out=new Out(os).out;
return this;
}
public IOTask setIO(File is,File os)throws IOException{
in=new In(is);
out=new Out(os).out;
return this;
}
void run()throws IOException{
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | d8d9636dc405b78c734ddaffd92d775e | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.io.*;
import java.util.*;
public class knight {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
int t = Integer.parseInt(br.readLine());
for (int i = 0; i < t; i++) {
int n, m;
StringTokenizer st = new StringTokenizer(br.readLine());
n = Integer.parseInt(st.nextToken());
m = Integer.parseInt(st.nextToken());
if (n > 4 && m > 2) {
pw.println(1 + " " + 1);
continue;
}
if (n > 2 && m > 4) {
pw.println(1 + " " + 1);
continue;
}
pw.println((n + 1) / 2 + " " + (m + 1) / 2);
}
pw.close();
br.close();
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 979a5b173bc169c7f388379b4788d37c | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class immobileknight {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int testCases = scanner.nextInt();
for (int i = 0; i < testCases; i++){
int rows = scanner.nextInt();
int columns = scanner.nextInt();
if (rows == 1 || columns == 1){
System.out.println(rows);
System.out.println(columns);
}
else if (rows == 2 && columns == 2){
System.out.println(rows);
System.out.println(columns);
}
else if (rows == 3 && columns == 3) {
System.out.println(2);
System.out.println(2);
}
else if ((rows == 2 && columns == 3) || (rows == 3 && columns == 2)){
System.out.println(2);
System.out.println(2);
}
else {System.out.println(1);System.out.println(1);}
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 8409d1a9f70944d45abf91e5b6e07023 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class P1739A {
static public boolean validMove(int x, int y, int width, int height, int xMove, int yMove) {
if (x + xMove >= 1 && x + xMove <= width) {
if (y + yMove >= 1 && y + yMove <= height) {
return true;
}
}
return false;
}
static public boolean canMove(int x, int y, int width, int height) {
for (int xDir = -1; xDir <= 1; xDir += 2) {
for (int yDir = -1; yDir <= 1; yDir += 2) {
if (validMove(x, y, width, height, xDir, yDir * 2)) return true;
if (validMove(x, y, width, height, xDir * 2, yDir)) return true;
}
}
return false;
}
static public String findIsolatedCell(int width, int height) {
for (int x = 1; x <= width; x++) {
for (int y = 1; y <= height; y++) {
if (!canMove(x, y, width, height)) return "" + x + " " + y;
}
}
return width + " " + height;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int testCount = scanner.nextInt();
int[] testCases = new int[testCount * 2];
for (int i = 0; i < testCount * 2; i += 2) {
testCases[i] = scanner.nextInt();
testCases[i + 1] = scanner.nextInt();
}
for (int i = 0; i < testCount * 2; i += 2) {
System.out.println(findIsolatedCell(testCases[i], testCases[i + 1]));
}
scanner.close();
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 376a020a7e2c8d3c552630fc30350682 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | // package cf1739.a;
import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int t = s.nextInt();
while (t-- > 0) {
int m = s.nextInt();
int n = s.nextInt();
String result = cf1739a(m, n);
System.out.println(result);
}
s.close();
}
private static String cf1739a(int m, int n) {
return (int) Math.ceil(m / 2.0) + " " + (int) Math.ceil(n / 2.0);
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 6e57915e8b3d6cddb16848c60fe2cb17 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
import java.io.*;
public class User {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String [] line = br.readLine().split(" ");
int t = Integer.parseInt(line[0]);
for(int i = 0; i < t; i++) {
line = br.readLine().split(" ");
int n = Integer.parseInt(line[0]), m = Integer.parseInt(line[1]);
showResult(n, m);
}
br.close();
}
static void showResult(int n, int m) {
int[][] dist = {
{-1, -2},
{-2, -1},
{-2, 1},
{-1, 2}
};
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
boolean flag = true;
for (int[] d : dist) {
if (!(i + d[0] > n || j + d[1] > m || i + d[0] < 1 || j + d[1] < 1)) {
flag = false; break;
}
if (!(i - d[0] > n || j - d[1] > m || i - d[0] < 1 || j - d[1] < 1)) {
flag = false; break;
}
}
if(flag){System.out.println(i + " " + j); return;}
}
}
System.out.println(n + " " + m);
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 17da1acf2521403a9262387e4091d584 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int testCases = scanner.nextInt();
for (int i = 0; i < testCases; ++i) {
int n = scanner.nextInt();
int m = scanner.nextInt();
if (n == 3 && m == 3) {
System.out.println("2 2");
}
else if (n <= 2 && m > 1) {
System.out.println("1 2");
}
else if (n > 1 && m <= 2) {
System.out.println("2 1");
}
else {
System.out.println("1 1");
}
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 5c1b3e7d5835679b15fb7f5d81984dca | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class problemA{
public static void main(String[] args) {
Scanner sh = new Scanner(System.in);
int t = sh.nextInt();
while(t>0){
int n = sh.nextInt();
int m = sh.nextInt();
if(n==1 || m==1){
System.out.println("1 1");
}else{
System.out.println("2 2");
}
t--;}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | b456716c1ea71ab83a67529cef17e877 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.security.KeyStore.Entry;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;
public class Main{
static class FastReader{
BufferedReader br;
StringTokenizer st;
public FastReader(){
br=new BufferedReader(new InputStreamReader(System.in));
}
String next(){
while(st==null || !st.hasMoreTokens()){
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt(){
return Integer.parseInt(next());
}
long nextLong(){
return Long.parseLong(next());
}
double nextDouble(){
return Double.parseDouble(next());
}
String nextLine(){
String str="";
try {
str=br.readLine().trim();
} catch (Exception e) {
e.printStackTrace();
}
return str;
}
}
static class FastWriter {
private final BufferedWriter bw;
public FastWriter() {
this.bw = new BufferedWriter(new OutputStreamWriter(System.out));
}
public void print(Object object) throws IOException {
bw.append("" + object);
}
public void println(Object object) throws IOException {
print(""+object);
bw.append("\n");
}
public void close() throws IOException {
bw.close();
}
}
///
static Scanner sl = new Scanner(System.in);
public static void main(String[] args) {
FastReader s=new FastReader();
// FastWriter out = new FastWriter();
int t = s.nextInt();
while(t-->0){
int n =s.nextInt();
int m = s.nextInt();
n /=2;
m /=2;
System.out.println((n+1)+" "+(m+1));
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 7001e71ad67943a6c63a3a38f8903e50 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class ImmobileKnight {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
for(int i = 0; i < t; i++) {
int n = scan.nextInt();
int m = scan.nextInt();
outerloop:
for(int j = 1; j <= n; j++) {
for(int k = 1; k <= m; k++) {
//System.out.print(j + " " + k + " ");
if((!(k + 2 <= m) && !(j + 3 <= n)) && (!(k + 3 <= m) && !(j + 2 <= n))) {
System.out.println(j + " " + k);
break outerloop;
}
else if(j == n && k == m) {
System.out.println(j + " " + k);
}
}
}
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 38da88754c79cc6e9ee17a86280b3994 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int tc = 0; tc < t; ++tc) {
int n = sc.nextInt();
int m = sc.nextInt();
System.out.println(solve(n, m));
}
sc.close();
}
static String solve(int n, int m) {
for (int r = 1; r <= n; ++r) {
for (int c = 1; c <= m; ++c) {
if (isIsolated(n, m, r, c)) {
return String.format("%d %d", r, c);
}
}
}
return "1 1";
}
static boolean isIsolated(int n, int m, int r, int c) {
for (int dr = -2; dr <= 2; ++dr) {
for (int dc = -2; dc <= 2; ++dc) {
if (Math.abs(dr * dc) == 2 && r + dr >= 1 && r + dr <= n && c + dc >= 1 && c + dc <= m) {
return false;
}
}
}
return true;
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 007c5052182dd2867a31d481925bb4e3 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
// Map.Entry<Integer,String>dum;
//res=(num1>num2) ? (num1+num2):(num1-num2)
/* Name of the class has to be "Main" only if the class is public. */
public class Pupil
{
static FastReader sc = new FastReader();
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
int t=sc.nextInt();
while(t>0){
Solve();
t--;
}
}
public static void Solve()
{
int n=sc.nextInt();
int m=sc.nextInt();
if(n==1 || m==1)
{
System.out.println(n+" "+m);return;
}
else if(n==3 && m==3)
{
System.out.println((n-1)+" "+(m-1) ); return;
}
if((n==2 && m<=3) || (m==2 && n<=3) )
{
System.out.println("2 2");
return ;
}
System.out.println(n+" "+m);
return;
}
// FAST I/O
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
public static boolean two(int n)//power of two
{
if((n&(n-1))==0)
{
return true;
}
else{
return false;
}
}
public static int factorial(int n)
{
int res = 1, i;
for (i = 2; i <= n; i++)
res *= i;
return res;
}
public static boolean isPrime(long n){
for (int i = 2; i * i <= n; ++i) {
if (n % i == 0) {
return false;
}
}
return true;
}
public static int digit(int n)
{
int n1=(int)Math.floor((int)Math.log10(n)) + 1;
return n1;
}
public static long gcd(long a,long b) {
if(b==0)
return a;
return gcd(b,a%b);
}
public static long highestPowerof2(long x)
{
// check for the set bits
x |= x >> 1;
x |= x >> 2;
x |= x >> 4;
x |= x >> 8;
x |= x >> 16;
// Then we remove all but the top bit by xor'ing the
// string of 1's with that string of 1's shifted one to
// the left, and we end up with just the one top bit
// followed by 0's.
return x ^ (x >> 1);
}
public static void yes()
{
System.out.println("YES");
return;
}
public static void no()
{
System.out.println("NO");
return ;
}
public static void al(long arr[],int n)
{
for(int i=0;i<n;i++)
{
arr[i]=sc.nextLong();
}
return ;
}
public static void iswap(int[]arr,int i,int j){
arr[i]^=arr[j];
arr[j]^=arr[i];
arr[i]^=arr[j];
}
public static void lswap(long[]arr,int i,int j){
long temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
public static void ai(int arr[],int n)
{
for(int i=0;i<n;i++)
{
arr[i]=sc.nextInt();
}
return ;
}
public static void makeSet(int parent[],int rank[]){
for(int i=0;i<100;i++)
{
parent[i]=i;
rank[i]=0;
}
}
public static int findParent(int node,int parent[])
{
if(node==parent[node])
{
return parent[node];
}
return parent[node]=findParent(parent[node], parent);
}
public static void union(int u,int v,int parent[],int rank[])
{
u=findParent(u,parent);
v=findParent(v,parent);
if(rank[u]<rank[v])
{
parent[u]=v;
}
else if(rank[u]>rank[v])
{
parent[v]=u;
}
else{
parent[v]=u;
rank[u]++;
}
}
}
//HashMap<Integer, Integer> map = new HashMap<>();
//for (int i = 0; i < n; i++) {
// int x = in.nextInt();
// int count = map.get(x) == null ? 0 : map.get(x);
// map.put(x, count + 1);
//}
//CAAL THE BELOW FUNCTION IF PARING PRIORITY IS NEEDED //
// PriorityQueue<pair> pq = new PriorityQueue<>(); **********declare the syntax in the main function******
// pq.add(1,2)///////
// class pair implements Comparable<pair> {
// int value, index;
// pair(int v, int i) { index = i; value = v; }
// @Override
// public int compareTo(pair o) { return o.value - value; }
// }
//o.value-value DESCENDING ORDER
//value-o.value ASCENDING ORDER
// User defined Pair class
// class Pair {
// int x;
// int y;
// // Constructor
// public Pair(int x, int y)
// {
// this.x = x;
// this.y = y;
// }
// }
// Arrays.sort(arr, new Comparator<Pair>() {
// @Override public int compare(Pair p1, Pair p2)
// {
// return p1.x - p2.x;
// }
// });
// class Pair {
// int height, id;
//
// public Pair(int i, int s) {
// this.height = s;
// this.id = i;
// }
// }
//Arrays.sort(trips, (a, b) -> Integer.compare(a[1], b[1]));
// ArrayList<ArrayList<Integer>> connections = new ArrayList<ArrayList<Integer>>();
// for(int i = 0; i<n;i++)
// connections.add(new ArrayList<Integer>());
//WHENEVER CIRCULAR ARRAY COMES ALWAYS CREATE A NEW ARRAY OF LENGTH (2*LENGTH OF ORIGINAL ARRAY)
//Integer.bitCount(i) counts number of times 1 appear in binary string of i | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | b7f54468ac8149d42603a08d4b0d0558 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
import java.io.*;
public class A {
final int mod = 1000000007;
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
public static void swap(long[] a, int i, int j) {
long temp = a[i];
a[i] = a[j];
a[j] = temp;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
FastReader t = new FastReader();
PrintWriter o = new PrintWriter(System.out);
int test = t.nextInt();
while (test-- > 0) {
long min = Integer.MIN_VALUE, max = Integer.MAX_VALUE;
long ans =0 ;
int n = t.nextInt();
int m = t.nextInt();
//long k = t.nextLong();
n = Math.max(n-1, 1);
m = Math.max(m-1, 1);
o.println(n+" "+m);
// long m = t.nextLong();
// int[] a = new int[n];
// ArrayList<Integer> al = new ArrayList<>();
// HashSet<Integer> set = new HashSet<>();
// HashMap<Integer, Integer> map = new HashMap<>();
// TreeMap<Integer, Integer> map = new TreeMap<>();
// for (int i = 0; i < n; ++i) {
// a[i] = t.nextInt();
// }
// for (int i = 0; i < n; ++i) {
// for (int j = 0; j < n; ++j) {
// }
// }
}
o.flush();
o.close();
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 684a1ab97ee80c2e0dd9c93b7ab24fc1 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import static java.lang.System.out;
import static java.lang.Math.abs;
import static java.lang.Math.min;
import static java.lang.Math.max;
import static java.lang.Math.log10;
import java.util.*;
import java.lang.*;
import java.io.*;
public class a_Codeforces {
public static void main(String[] args) throws java.lang.Exception {
FastReader sc = new FastReader();
FastWriter out = new FastWriter();
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int m = sc.nextInt();
if (min(n, m) < 2 || max(n, m) < 4) {
int x = (n % 2 == 0) ? n / 2 : n / 2 + 1;
int y = (m % 2 == 0) ? m / 2 : m / 2 + 1;
out.println(x + " " + y);
} else {
out.println("1 1");
}
}
out.close();
}
/*
* int[] x = new int[n];
* for (int i=0; i<n; i++){
* x[i] = sc.nextInt();
* }
*/
static void no() {
out.println("NO");
}
static void yes() {
out.println("YES");
}
static void m1() {
out.println("-1");
}
static void print(int x[]) {
for (int i = 0; i < x.length; i++) {
out.print(x[i] + " ");
}
out.println("");
}
static int[] input(int n) {
FastReader sc = new FastReader();
int[] x = new int[n];
for (int i = 0; i < n; i++) {
x[i] = sc.nextInt();
}
return x;
}
static int[] swap(int x[], int a, int b) {
int temp = x[b];
x[b] = x[a];
x[a] = temp;
return x;
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreTokens()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine().trim();
} catch (Exception e) {
e.printStackTrace();
}
return str;
}
}
static class FastWriter {
private final BufferedWriter bw;
public FastWriter() {
this.bw = new BufferedWriter(new OutputStreamWriter(System.out));
}
public void print(Object object) throws IOException {
bw.append("" + object);
}
public void println(Object object) throws IOException {
print(object);
bw.append("\n");
}
public void close() throws IOException {
bw.close();
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | e0c67b902930e9e83960b65adfb389d1 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main{
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine());
while(t-- > 0){
String[] s = br.readLine().split(" ");
int rows = Integer.parseInt(s[0]);
int cols = Integer.parseInt(s[1]);
int centreRow = rows/2 + 1;
int centreCol = cols/2 + 1;
if(rows == 1 || cols == 1){
System.out.println(rows+" "+cols);
}else if((centreRow <= 2 && centreCol <= 2) && ((rows-centreRow) <= 2 && (cols-centreCol) <= 2)){
System.out.println(centreRow+" "+centreCol);
}else System.out.println(1+" "+1);
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 25f4bfa7d8f74a2eac3762a93bc00df8 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
import java.io.*;
import java.security.*;
public class solution {
public static void main(String[] args) throws Exception {
Scanner input;
try {
File file = new File("/home/harsh/Documents/Codes/input.txt");
FileInputStream fis = new FileInputStream(file);
input = new Scanner(fis);
} catch (Exception e) {
input = new Scanner(System.in);
}
int testcases = input.nextInt();
while (--testcases >= 0) {
solve(input);
}
input.close();
}
private static void solve(Scanner input) throws Exception {
int n = input.nextInt(), m = input.nextInt();
if((n&1)==1) n = (n+1)/2;
else n = n/2;
if((m&1)==1) m = (m+1)/2;
else m = m/2;
System.out.println(n+" "+m);
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 47f66e59448e67eb15944bae91cf8191 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class Codechef
{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
int test=sc.nextInt();
while(test-->0)
{
// System.out.println(solve(sc));
solve(sc);
}
sc.close();
}
public static void solve(Scanner sc){
int a=sc.nextInt();
int b=sc.nextInt();
if(a>3 && b>3)
System.out.println(a+" "+b);
else
System.out.println((a/2+1)+" "+(b/2+1));
}
}
class define{
public static long power( long a,long b)
{
long res = 1;
while (b > 0) {
if ((b & 1)==1)
res = (res * a);
a = a * a;
b >>= 1;
}
return res;
}
public static int power( int a,int b)
{
int res = 1;
while (b > 0) {
if ((b & 1)==1)
res = (res * a);
a = a * a;
b >>= 1;
}
return res;
}
public static void printarray( long a[])
{
for(long i:a)
System.out.print(i+" ");
System.out.println();
}
public static void printarray( int a[])
{
for(int i:a)
System.out.print(i+" ");
System.out.println();
}
public static void printarraylist( ArrayList<Integer>a)
{
for(int i:a)
System.out.print(i+" ");
System.out.println();
}
public static void swap( long a,long b)
{
a=a^b;
b=a^b;
a=a^b;
System.out.println(a+" "+b);
}
public static void swap( int a,int b)
{
a=a^b;
b=a^b;
a=a^b;
System.out.println(a+" "+b);
}
public static int maxxorbetweentwonumber( int a,int b)
{
int store=a^b;
int count=0;
while(store>0)
{
count++;
store=store>>1;
}
int res=1;
int ans=0;
while(count-->0)
{
ans+=res;
res=res<<1;
}
return ans;
}
public static void sort(int arr[])
{
Arrays.sort(arr);
}
public static int[] insertarray(Scanner sc,int n)
{
int arr[]=new int[n];
for(int i=0;i<n;i++)
arr[i]=sc.nextInt();
return arr;
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 50be378b6c7e86d5210f1902d61f7641 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | /**/
import java.io.*;
import java.util.*;
import java.lang.*;
public class ImmobileKnight {
public static void main(String[] args) throws IOException{
FastReader s = new FastReader();
PrintWriter out = new PrintWriter(System.out);
int t = s.nextInt();
while(t-->0){
int n = s.nextInt();
int m = s.nextInt();
if((n < 4 && m < 4) || n == 1 || m == 1){
out.println((n/2 + 1) + " " + (m/2 + 1));
}
else{
out.println(1 + " " + 1);
}
}
out.flush();
}
public static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
public String next() throws IOException {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() throws IOException {
return Integer.parseInt(next());
}
long nextLong() throws IOException {
return Long.parseLong(next());
}
double nextDouble() throws IOException {
return Double.parseDouble(next());
}
String nextLine() throws IOException {
String str = "";
if (st.hasMoreTokens()) {
str = st.nextToken("\n");
} else {
str = br.readLine();
}
return str;
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 8ab460cab970732561f37cc3814da488 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
import java.util.function.*;
import java.io.*;
// you can compare with output.txt and expected out
public class RoundEdu136A {
MyPrintWriter out;
MyScanner in;
// final static long FIXED_RANDOM;
// static {
// FIXED_RANDOM = System.currentTimeMillis();
// }
final static String IMPOSSIBLE = "IMPOSSIBLE";
final static String POSSIBLE = "POSSIBLE";
final static String YES = "YES";
final static String NO = "NO";
private void initIO(boolean isFileIO) {
if (System.getProperty("ONLINE_JUDGE") == null && isFileIO) {
try{
in = new MyScanner(new FileInputStream("input.txt"));
out = new MyPrintWriter(new FileOutputStream("output.txt"));
}
catch(FileNotFoundException e){
e.printStackTrace();
}
}
else{
in = new MyScanner(System.in);
out = new MyPrintWriter(new BufferedOutputStream(System.out));
}
}
public static void main(String[] args){
// Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
// the code for the deep recursion (more than 100k or 3~400k or so)
// Thread t = new Thread(null, new RoundEdu130F(), "threadName", 1<<28);
// t.start();
// t.join();
RoundEdu136A sol = new RoundEdu136A();
sol.run();
}
private void run() {
boolean isDebug = false;
boolean isFileIO = true;
boolean hasMultipleTests = true;
initIO(isFileIO);
int t = hasMultipleTests? in.nextInt() : 1;
for (int i = 1; i <= t; ++i) {
if(isDebug){
out.printf("Test %d\n", i);
}
getInput();
solve();
printOutput();
}
in.close();
out.close();
}
// use suitable one between matrix(2, n), matrix(n, 2), transposedMatrix(2, n) for graph edges, pairs, ...
int n, m;
void getInput() {
n = in.nextInt();
m = in.nextInt();
}
void printOutput() {
out.printlnAns(ans);
}
int[] ans;
void solve(){
ans = new int[2];
ans[0] = (n+1)/2;
ans[1] = (m+1)/2;
}
// Optional<T> solve()
// return Optional.empty();
static class Pair implements Comparable<Pair>{
final static long FIXED_RANDOM = System.currentTimeMillis();
int first, second;
public Pair(int first, int second) {
this.first = first;
this.second = second;
}
@Override
public int hashCode() {
// http://xorshift.di.unimi.it/splitmix64.c
long x = first;
x <<= 32;
x += second;
x += FIXED_RANDOM;
x += 0x9e3779b97f4a7c15l;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9l;
x = (x ^ (x >> 27)) * 0x94d049bb133111ebl;
return (int)(x ^ (x >> 31));
}
@Override
public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null)
// return false;
// if (getClass() != obj.getClass())
// return false;
Pair other = (Pair) obj;
return first == other.first && second == other.second;
}
@Override
public String toString() {
return "[" + first + "," + second + "]";
}
@Override
public int compareTo(Pair o) {
int cmp = Integer.compare(first, o.first);
return cmp != 0? cmp: Integer.compare(second, o.second);
}
}
public static class MyScanner {
BufferedReader br;
StringTokenizer st;
// 32768?
public MyScanner(InputStream is, int bufferSize) {
br = new BufferedReader(new InputStreamReader(is), bufferSize);
}
public MyScanner(InputStream is) {
br = new BufferedReader(new InputStreamReader(is));
// br = new BufferedReader(new InputStreamReader(System.in));
// br = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt")));
}
public void close() {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine(){
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
int[][] nextMatrix(int n, int m) {
return nextMatrix(n, m, 0);
}
int[][] nextMatrix(int n, int m, int offset) {
int[][] mat = new int[n][m];
for(int i=0; i<n; i++) {
for(int j=0; j<m; j++) {
mat[i][j] = nextInt()+offset;
}
}
return mat;
}
int[][] nextTransposedMatrix(int n, int m){
return nextTransposedMatrix(n, m, 0);
}
int[][] nextTransposedMatrix(int n, int m, int offset){
int[][] mat = new int[m][n];
for(int i=0; i<n; i++) {
for(int j=0; j<m; j++) {
mat[j][i] = nextInt()+offset;
}
}
return mat;
}
int[] nextIntArray(int len) {
return nextIntArray(len, 0);
}
int[] nextIntArray(int len, int offset){
int[] a = new int[len];
for(int j=0; j<len; j++)
a[j] = nextInt()+offset;
return a;
}
long[] nextLongArray(int len) {
return nextLongArray(len, 0);
}
long[] nextLongArray(int len, int offset){
long[] a = new long[len];
for(int j=0; j<len; j++)
a[j] = nextLong()+offset;
return a;
}
String[] nextStringArray(int len) {
String[] s = new String[len];
for(int i=0; i<len; i++)
s[i] = next();
return s;
}
}
public static class MyPrintWriter extends PrintWriter{
public MyPrintWriter(OutputStream os) {
super(os);
}
// public <T> void printlnAns(Optional<T> ans) {
// if(ans.isEmpty())
// println(-1);
// else
// printlnAns(ans.get());
// }
public void printlnAns(OptionalInt ans) {
println(ans.orElse(-1));
}
public void printlnAns(long ans) {
println(ans);
}
public void printlnAns(int ans) {
println(ans);
}
public void printlnAns(boolean[] ans) {
for(boolean b: ans)
printlnAns(b);
}
public void printlnAns(boolean ans) {
if(ans)
println(YES);
else
println(NO);
}
public void printAns(long[] arr){
if(arr != null && arr.length > 0){
print(arr[0]);
for(int i=1; i<arr.length; i++){
print(" ");
print(arr[i]);
}
}
}
public void printlnAns(long[] arr){
printAns(arr);
println();
}
public void printAns(int[] arr){
if(arr != null && arr.length > 0){
print(arr[0]);
for(int i=1; i<arr.length; i++){
print(" ");
print(arr[i]);
}
}
}
public void printlnAns(int[] arr){
printAns(arr);
println();
}
public <T> void printAns(ArrayList<T> arr){
if(arr != null && arr.size() > 0){
print(arr.get(0));
for(int i=1; i<arr.size(); i++){
print(" ");
print(arr.get(i));
}
}
}
public <T> void printlnAns(ArrayList<T> arr){
printAns(arr);
println();
}
public void printAns(int[] arr, int add){
if(arr != null && arr.length > 0){
print(arr[0]+add);
for(int i=1; i<arr.length; i++){
print(" ");
print(arr[i]+add);
}
}
}
public void printlnAns(int[] arr, int add){
printAns(arr, add);
println();
}
public void printAns(ArrayList<Integer> arr, int add) {
if(arr != null && arr.size() > 0){
print(arr.get(0)+add);
for(int i=1; i<arr.size(); i++){
print(" ");
print(arr.get(i)+add);
}
}
}
public void printlnAns(ArrayList<Integer> arr, int add){
printAns(arr, add);
println();
}
public void printlnAnsSplit(long[] arr, int split){
if(arr != null){
for(int i=0; i<arr.length; i+=split){
print(arr[i]);
for(int j=i+1; j<i+split; j++){
print(" ");
print(arr[j]);
}
println();
}
}
}
public void printlnAnsSplit(int[] arr, int split){
if(arr != null){
for(int i=0; i<arr.length; i+=split){
print(arr[i]);
for(int j=i+1; j<i+split; j++){
print(" ");
print(arr[j]);
}
println();
}
}
}
public <T> void printlnAnsSplit(ArrayList<T> arr, int split){
if(arr != null && !arr.isEmpty()){
for(int i=0; i<arr.size(); i+=split){
print(arr.get(i));
for(int j=i+1; j<i+split; j++){
print(" ");
print(arr.get(j));
}
println();
}
}
}
}
static private void permutateAndSort(long[] a) {
int n = a.length;
Random R = new Random(System.currentTimeMillis());
for(int i=0; i<n; i++) {
int t = R.nextInt(n-i);
long temp = a[n-1-i];
a[n-1-i] = a[t];
a[t] = temp;
}
Arrays.sort(a);
}
static private void permutateAndSort(int[] a) {
int n = a.length;
Random R = new Random(System.currentTimeMillis());
for(int i=0; i<n; i++) {
int t = R.nextInt(n-i);
int temp = a[n-1-i];
a[n-1-i] = a[t];
a[t] = temp;
}
Arrays.sort(a);
}
static private int[][] constructChildren(int n, int[] parent, int parentRoot){
int[][] childrens = new int[n][];
int[] numChildren = new int[n];
for(int i=0; i<parent.length; i++) {
if(parent[i] != parentRoot)
numChildren[parent[i]]++;
}
for(int i=0; i<n; i++) {
childrens[i] = new int[numChildren[i]];
}
int[] idx = new int[n];
for(int i=0; i<parent.length; i++) {
if(parent[i] != parentRoot)
childrens[parent[i]][idx[parent[i]]++] = i;
}
return childrens;
}
static private int[][][] constructDirectedNeighborhood(int n, int[][] e){
int[] inDegree = new int[n];
int[] outDegree = new int[n];
for(int i=0; i<e.length; i++) {
int u = e[i][0];
int v = e[i][1];
outDegree[u]++;
inDegree[v]++;
}
int[][] inNeighbors = new int[n][];
int[][] outNeighbors = new int[n][];
for(int i=0; i<n; i++) {
inNeighbors[i] = new int[inDegree[i]];
outNeighbors[i] = new int[outDegree[i]];
}
for(int i=0; i<e.length; i++) {
int u = e[i][0];
int v = e[i][1];
outNeighbors[u][--outDegree[u]] = v;
inNeighbors[v][--inDegree[v]] = u;
}
return new int[][][] {inNeighbors, outNeighbors};
}
static private int[][] constructNeighborhood(int n, int[][] e) {
int[] degree = new int[n];
for(int i=0; i<e.length; i++) {
int u = e[i][0];
int v = e[i][1];
degree[u]++;
degree[v]++;
}
int[][] neighbors = new int[n][];
for(int i=0; i<n; i++)
neighbors[i] = new int[degree[i]];
for(int i=0; i<e.length; i++) {
int u = e[i][0];
int v = e[i][1];
neighbors[u][--degree[u]] = v;
neighbors[v][--degree[v]] = u;
}
return neighbors;
}
static private void drawGraph(int[][] e) {
makeDotUndirected(e);
try {
final Process process = new ProcessBuilder("dot", "-Tpng", "graph.dot")
.redirectOutput(new File("graph.png"))
.start();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
static private void makeDotUndirected(int[][] e) {
MyPrintWriter out2 = null;
try {
out2 = new MyPrintWriter(new FileOutputStream("graph.dot"));
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
out2.println("strict graph {");
for(int i=0; i<e.length; i++){
out2.println(e[i][0] + "--" + e[i][1] + ";");
}
out2.println("}");
out2.close();
}
static private void makeDotDirected(int[][] e) {
MyPrintWriter out2 = null;
try {
out2 = new MyPrintWriter(new FileOutputStream("graph.dot"));
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
out2.println("strict digraph {");
for(int i=0; i<e.length; i++){
out2.println(e[i][0] + "->" + e[i][1] + ";");
}
out2.println("}");
out2.close();
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | f28af9c86ddb3723d451328b504ad530 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int m=sc.nextInt();
int n=sc.nextInt();
if(m==1||n==1){
System.out.println(m+" "+n);
}
else if(m>1&&n>1) {
System.out.println((m-1)+" "+(n-1));
}
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 7131cb72c1ba6e22561c7c4da29513b0 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class A136 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
for (int l = 0;l < t;l++){
int n = scanner.nextInt();
int m = scanner.nextInt();
int[] ns = {1,2,3,4,5,6,7,8};
int[] ms = {1,2,3,4,5,6,7,8};
int resultn = 0 ;
int resultm = 0 ;
for (int i = 0;i < n;i++){
for (int j = 0;j < m;j++){
if (((ns[i]+1<=n&&ms[j]+2<=m)||
(ns[i]+1<=n&&ms[j]-2<=m&&ms[j]-2>=1)||
(ns[i]+2<=n&&ms[j]+1<=m && ms[j]-2>=1)||
(ns[i]+2<=n&&ms[j]-1<=m && ms[j]-1>=1)||
(ns[i]-1<=n&&ms[j]+2<=m && ns[i]-1>=1)||
(ns[i]-1<=n&&ms[j]-2<=m && ns[i]-1>=1 && ms[j]-2>=1)||
(ns[i]-2<=n&&ms[j]+1<=m && ns[i]-2>=1)||
(ns[i]-2<=n&&ms[j]-1<=m && ns[i]-2>=1 && ms[j]-1>=1)))
{}
else {
resultn = ns[i];
resultm = ms[j];
}
}}
if (resultn==0&&resultm==0) System.out.println(1 + " "+ 1);
else System.out.println(resultn+" "+resultm);
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | c07f9b6ff739d3c6e26c61d182152ba6 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.io.*;
import java.util.*;
public class codeForces {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
if(st.hasMoreTokens()){
str = st.nextToken("\n");
}
else{
str = br.readLine();
}
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
public static void main(String[] args) {
FastReader sc = new FastReader();
int t = sc.nextInt();
while (t-->0) {
int x = sc.nextInt();
int y = sc.nextInt();
boolean ansfound = false;
for (int i=1; i<=x; i++) {
for (int j=1; j<=y; j++) {
int inrange = 0;
int[][] arr = new int[8][2];
arr[0][0] = i-2;
arr[0][1] = j-1;
arr[1][0] = i-2;
arr[1][1] = j+1;
arr[2][0] = i-1;
arr[2][1] = j-2;
arr[3][0] = i-1;
arr[3][1] = j+2;
arr[4][0] = i+1;
arr[4][1] = j-2;
arr[5][0] = i+1;
arr[5][1] = j+2;
arr[6][0] = i+2;
arr[6][1] = j-1;
arr[7][0] = i+2;
arr[7][1] = j+1;
for (int k = 0; k<arr.length; k++) {
if (arr[k][0] > 0 && arr[k][1]>0 && arr[k][0]<=x && arr[k][1]<=y)
inrange++;
}
if (inrange == 0) {
ansfound = true;
System.out.println(i + " " + j);
break;
}
}
if (ansfound)
break;
}
if (ansfound) {
ansfound = false;
}
else {
System.out.println("1 1");
}
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 9cb9eb5e741907984028b30b73a2aed0 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class forces {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t;
t=sc.nextInt();
while(t-->0)
{
int m,n;
n=sc.nextInt();
m=sc.nextInt();
if(m==1||n==1)
{
System.out.println(1+" "+1);
}
else if(m==2&&n>=4)
{
System.out.println(1+" "+1);
}
else if(m>=4&&n==2)
{
System.out.println(1+" "+1);
}
else if(m<=2&&n<=2)
{
System.out.println(1+" "+1);
}
else if(m==2&&n==3)
{
System.out.println(2+" "+1);
}
else if(m==3&&n==2)
{
System.out.println(1+" "+2);
}
else if(m==3&&n==3)
{
System.out.println(2+" "+2);
}
else
{
System.out.println(1+" "+1);
}
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 8038867c85194edc9a6f671e476bd896 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class Immobile_Knight {
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();
if (n == 1 || m == 1) {
System.out.println(n + " " + m);
} else if (n <= 3 && m <= 3) {
System.out.println(2 + " " + 2);
} else {
System.out.print(n - 1);
System.out.print(" ");
System.out.print(m - 1);
System.out.println();
}
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 92760e63f69dfb5169cb5cc1fa32532a | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class main{
public static void main(String args[]){
Scanner s=new Scanner(System.in);
int t=s.nextInt();
while(t-->0){
int a=s.nextInt();
int b=s.nextInt();
if(a==1 || b==1) System.out.println(a+" "+b);
else if(a<=3 && b<=3) System.out.println("2 2");
else System.out.println((a-1)+" "+(b-1));
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 91427df7e536d16bb2f7c53ce388ef6a | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class contest_3 {
public static void main(String[] args) {
try {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
int rows = sc.nextInt();
int cols = sc.nextInt();
int[] x = new int[]{2, 2, -2, -2, 1, -1, 1, -1};
int[] y = new int[]{1, -1, 1, -1, 2, 2, -2, -2};
int ansRow = -1;
int ansCol = -1;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
boolean isPossible = false;
for (int k = 0; k < 8; k++) {
int tempRow = i + x[k];
int tempCol = j + y[k];
if (tempRow >= 0 && tempCol >= 0 && tempRow < rows && tempCol < cols) {
isPossible = true;
break;
}
}
if (isPossible == false) {
ansRow=i+1;
ansCol=j+1;
break;
}
}
if(ansCol!=-1)
break;
}
if(ansCol!=-1)
System.out.println(ansRow + " " + ansCol);
else
System.out.println(rows + " " + cols);
}
}catch (Exception e){
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 8e54fcd68b5ab7b739d328062c3f5aab | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | /* package codechef; // 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 Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner scan = new Scanner(System.in);
int num = scan.nextInt();
while(num-->0){
int m=scan.nextInt(),n = scan.nextInt();
if(m==3 && n ==3) System.out.println(2+" "+2);
else if (m==2 && n==3 ) System.out.println(1+" "+2);
else if(m==3 && n==2) System.out.println(2+" "+1);
else System.out.println(1+" "+1);
}
scan.close();
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 4fbc4d674c36651711010debab7f9752 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int numCases = in.nextInt();
for (int i = 0; i < numCases; i++) {
int height = in.nextInt();
int width = in.nextInt();
if (height == 1 || width == 1) {
System.out.println("1 1");
continue;
}
if (height < 4 && width < 4) {
System.out.println("2 2");
continue;
}
System.out.println("1 1");
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 1bb2ceb74371352e09f90a113e926e9b | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input =new Scanner(System.in);
int x = Integer.parseInt(input.next());
for (int i = 0; i < x; i++) {
int n = input.nextInt();
int m = input.nextInt();
jud(n,m);
}
}
public static void jud(int n,int m){
boolean flag=true;
for (int i = 1; i <= n&& flag; i++) {
for (int j = 1; j <= m&& flag; j++) {
flag=false;
if (i - 2 > 0){
if (j-1>0||j+1<=m){
flag=true;
}
}
if (!flag &&i-1>0) {
if (j-2>0||j+2<=m){
flag=true;
}
}
if (!flag &&i+1<=n) {
if (j-2>0||j+2<=m){
flag=true;
}
}
if (!flag &&i+2<=n) {
if (j-1>0||j+1<=m){
flag=true;
}
}
if (!flag){
System.out.println(i+" "+j);
}
}
}
if (flag){
System.out.println("1 1");
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 64b400e98fb6bdebfd58b368627efee5 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.io.*;
import java.util.StringTokenizer;
import java.util.ArrayList;
public class Main {
static class Scanner {
public BufferedReader bufferedReader;
public StringTokenizer stringTokenizer;
public Scanner(InputStream stream) {
this.bufferedReader = new BufferedReader(new InputStreamReader(stream));
}
public String next() {
while (this.stringTokenizer == null || !this.stringTokenizer.hasMoreElements()) {
try {
this.stringTokenizer = new StringTokenizer(this.bufferedReader.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return this.stringTokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(this.next());
}
}
public static int[] findIsolatedCell(int n, int m) {
int[] cell = {n, m};
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if ((i + 2) > n && (i - 2) < 1 && (j + 2) > m && (j - 2) < 1) {
cell[0] = i;
cell[1] = j;
}
}
}
return cell;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
int[] n = new int[t];
int[] m = new int[t];
for (int i = 0; i < t; i++) {
n[i] = in.nextInt();
m[i] = in.nextInt();
}
for (int j = 0; j < t; j++) {
int[] cell = findIsolatedCell(n[j], m[j]);
System.out.println(cell[0] + " " + cell[1]);
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 17 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 55ec3052a60e23db24895c5235f18f07 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class ImmobileKnight {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
for(int i=0; i<t; i++) {
int n = scan.nextInt();
int m = scan.nextInt();
test(n, m);
}
}
public static void test(int n, int m) {
if(n==1 || m==1) {
System.out.println(n + " " + m);
}
else if(n<=3 && m<=3) {
System.out.println((int)Math.round((n+1)/2.0)+ " " + (int)Math.round((m+1)/2.0));
}
else {
int min = Math.min(n, m);
int max = Math.max(n, m);
System.out.println(n + " " + m);
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 38e13b47e3226d0559e8d05e05ab213a | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
import java.io.*;
public class MyClass {
public static void main(String args[]){
Scanner scn=new Scanner(System.in);
int t=scn.nextInt();
for(int i=0;i<t;i++){
int n=scn.nextInt();
int m=scn.nextInt();
int dx[]={1,1,2,2,-1,-1,-2,-2};
int dy[]={2,-2,1,-1,2,-2,1,-1};
int c2=0,flag=0;
for(int j=0;j<n;j++){
for(int k=0;k<m;k++){
int c=0;
for(int i1=0;i1<8;i1++){
int x2=dx[i1]+j,y2=dy[i1]+k;
if(x2>=n||y2>=m||x2<0||y2<0) c++;
}
if(c==8){
int x=j+1,y=k+1;
System.out.println(x+" "+y);
flag=1;
break;
}
else{
c2++;
}
}
if(flag==1){
break;
}
}
if(c2==n*m){
System.out.println(1+" "+1);
}
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 9ee533c1937f86ed31bc4dff22430f1b | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | //package Algorithm;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
public class Main {
static class Location {
int location;
int time;
Location(int location, int time) {
this.location = location;
this.time = time;
}
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer st = new StringTokenizer(br.readLine());
int T = Integer.parseInt(st.nextToken());
for (int test = 0; test < T; test++) {
st = new StringTokenizer(br.readLine());
int N = Integer.parseInt(st.nextToken());
int M = Integer.parseInt(st.nextToken());
int end = 0;
for(int i=1;i<=N;i++) {
int stop = 0;
for(int j=1;j<=M;j++) {
int[] row = {1,1,2,2,-1,-1,-2,-2};
int[] col = {-2,2,-1,1,-2,2,-1,1};
stop = 0;
//bw.write(i+" "+j+" "+stop+"\n");
for(int s = 0;s<8;s++) {
int x = i + row[s];
int y = j + col[s];
if((1<=x&&x<=N)&&(1<=y&&y<=M)) {
//bw.write(i+" "+j+" "+row[s]+" "+col[s]+"\n");
stop++;
break;
}
}
if(stop==0) {
bw.write(i+" "+j+"\n");
end++;
break;
}
}
if(stop==0) {
break;
}
}
if(end!=0) {
continue;
}
bw.write(1+" "+1+"\n");
}
bw.flush();
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | f03f9c7616e6c6ce267317c0fcff159a | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
while (t > 0) {
int n = scanner.nextInt();
int m = scanner.nextInt();
if (n == 2 && m > 1 && m < 4)
System.out.println(1 + " " + 2);
else if (n > 1 && n < 4 && m == 2)
System.out.println(2 + " " + 1);
else if (n == 3 && m == 3)
System.out.println("2 2");
else {
System.out.println(n + " " + m);
}
t--;
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 3a9f1503a9d546a455370c45dfdbe038 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | // Online Java Compiler
// Use this editor to write, compile and run your Java code online
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t= sc.nextInt();
for(int i = 0;i< t;i++){
int rows= sc.nextInt();
int columns= sc.nextInt();
if(rows == 3 & columns ==3){
System.out.printf("%d %d\n", 2, 2);
}
else if(rows == 3 & columns == 2){
System.out.printf("%d %d\n", 2, 1);
}
else if(rows == 2 & columns == 3){
System.out.printf("%d %d\n", 1, 2);
}
else{
System.out.printf("%d %d\n",rows,columns);
}
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | a84a445b583f02ed4a7da4ccd5d62ba8 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class Main
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
int m = 0;
int n = 0;
int row[] = {2,2,-2,-2,-1,-1,1,1};
int col[] = {-1,1,-1,1,2,-2,2,-2};
for(int k=0;k<t;k++)
{
m = sc.nextInt();boolean flag = false ;
n=sc.nextInt();
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{ flag= false ;
for(int mov=0;mov<8;mov++)
{
if((i+row[mov])<m&&-1<(i+row[mov]) && (j+col[mov])<n&&-1<(j+col[mov]))
{
flag = true;
continue;
}
}
if(flag==false ){
System.out.println((i+1)+" "+(j+1));
break;
}
}
if(flag==false )
break;
}
if(flag==true)
System.out.println(1+" "+1);
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 8138e3894889d109a104e8b7db84e012 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while(t-- > 0){
int n = in.nextInt();
int m = in.nextInt();
System.out.println((n/2 + 1) + " " + (m/2 + 1));
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | d8af0d43bf0965202c909c5f9a8f3b8e | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int t = scn.nextInt();
for (int i = 0; i < t; i++) {
int n = scn.nextInt();
int m = scn.nextInt();
int[] ans = findIsolatedIndex(n, m);
System.out.println(ans[0] + " " + ans[1]);
}
}
public static int[] findIsolatedIndex(int n, int m) {
int[][] dir = { { -2, 1 }, { -1, 2 }, { 1, 2 }, { 2, 1 }, { 2, -1 }, { 1, -2 }, { -1, -2 }, { -2, -1 } };
int[] ans = new int[2];
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
boolean flag = false;
for (int d = 0; d < dir.length; d++) {
int r = i + dir[d][0];
int c = j + dir[d][1];
if (r >= 1 && c >= 1 && r <= n && c <= m) {
flag = true;
}
}
if (!flag) {
ans[0] = i;
ans[1] = j;
return ans;
}
}
}
ans[0] = ans[1] = 1;
return ans;
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 6b920026533f2aedb939d0294a61d0ae | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class Immobile_Knight {
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();
if(n==3 || m == 3){
if(n==3 && m ==3){
System.out.println(2+" "+2);
}else if(m==3){
System.out.println(n+" "+2);
}else{
System.out.println(2+" "+m);
}
}else{
System.out.println(n +" "+m);
}
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 5359bc3c236c87ca1e5f7e5a73dcab89 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes |
import java.util.*;
import java.lang.*;
import java.math.BigInteger;
import java.io.*;
public class New {
public static void main (String[] args) throws java.lang.Exception
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
int testCases = Integer.parseInt(br.readLine());
// int testCases=1;
while(testCases-->0){
String input[] = br.readLine().split(" ");
int n = Integer.parseInt(input[0]);
int m = Integer.parseInt(input[1]);
if(n==1 || m==1) out.println(n+" "+m);
else if(n==3 && m==3) out.println(2+" "+2);
else if(n==3 && m==2) out.println(2+" "+1);
else if(n==2 && m==3) out.println(1+" "+2);
else out.println(n+" "+m);
}
out.close();
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 0b427278b2acc061663adfd064107564 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);;
int cases = input.nextInt();
for (int i = 0; i < cases; i++) {
func(input);
}
}
public static void func(Scanner input) {
int n = input.nextInt();
int m = input.nextInt();
if (n == 1 || m == 1) {
System.out.println("1 1");
return;
}
if (n == 2 && m == 2) {
System.out.println("1 1");
return;
}
if (n % 2 == 1 && n == m) {
System.out.println((n/2+1) + " " + (m/2+1));
return;
}
if (n == 2 && m == 3) {
System.out.println("1 2");
return;
}
System.out.println("2 1");
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | e42b86f984f7d053d0d476ddc0aaf88d | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class Main {
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();
if(n<2 || m<2){
System.out.println(n+" "+m);
}else{
System.out.println(2+" "+2);
}
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 71e8d5a416aeffb6c43b23788b1d7c73 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class q184 {
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();
if(n==1||m==1){
//saare cell isolated hoge
System.out.println(1+" "+1);
}else{
System.out.println(2+" "+2);
}
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | e37433636d0cd727e96cd4cd3a6b9d06 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
public static void main(String[] args)
{
FastReader sc = new FastReader();
int T = sc.nextInt();
while(T-->0){
int rows=sc.nextInt();
int col=sc.nextInt();
if((rows==2 && col==3)||(rows==3 && col==2) || (rows== 3 && col == 3) ){
System.out.println("2 2");
}
else if(rows<3 || col<3 ){
System.out.println(rows+" "+col);
}
else{
System.out.println("2 3");
}
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | c3edd171e296932e2ed67b276fa112bb | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
static long mod = 1000000007;
static int n , m;
static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
public static void main(String[] args) throws IOException {
FastReader sc = new FastReader();
int t = sc.nextInt();
while( t-- > 0) {
n = sc.nextInt();
m= sc.nextInt();
boolean check = false;
for( int i = 0 ;i < n && !check; i++) {
for(int j = 0; j < m ;j++){
if( see( i +2 , j+1) && see ( i+2 , j-1)&& see( i-2 , j+1) && see( i-2 , j-1) && see( i+1 , j+2)&& see( i-1 , j+2) && see( i-1 , j-2) && see(i+1 , j-2)) {
check = true;
out.println((i+1) +" " + (j+1));
break;
}
}
}
if( !check) {
out.println(1 + " " + 1);
}
}
out.flush();
}
private static boolean see(int i, int j) {
if( i < 0 || j < 0) {
return true;
}
if( i >= n || j >=m ) {
return true;
}
return false;
}
/*
* think of binary search
* look at test cases
* do significant case work
*/
static class DSU{
int n;
int[] leaders,size;
public DSU(int n){
this.n=n;
leaders=new int[n+1];
size=new int[n+1];
for(int i=1;i<=n;i++){
leaders[i]=i;
size[i]=1;
}
}
public int find(int a){
if(leaders[a]==a) return a;
return leaders[a]=find (leaders[a]);
}
public void merge(int a,int b){
a = find(a);
b = find(b);
if (a == b) return;
if (size[a] < size[b]) swap(a, b);
leaders[b] = a;
size[a] += size[b];
}
public void swap(int a,int b){
int temp=a;
a=b;
b=temp;
}
}
public static boolean ifpowof2(long n ) {
return ((n&(n-1)) == 0);
}
static boolean isprime(long x ) {
if( x== 2) {
return true;
}
if( x%2 == 0) {
return false;
}
for( long i = 3 ;i*i <= x ;i+=2) {
if( x%i == 0) {
return false;
}
}
return true;
}
static boolean[] sieveOfEratosthenes(long n) {
boolean prime[] = new boolean[(int)n + 1];
for (int i = 0; i <= n; i++) {
prime[i] = true;
}
for (long p = 2; p * p <= n; p++) {
if (prime[(int)p] == true) {
for (long i = p * p; i <= n; i += p)
prime[(int)i] = false;
}
}
return prime;
}
public List<Integer> goodIndices(int[] nums, int k) {
int n = nums.length;
int fst[] = nextLargerElement(nums, n);
int scnd[] = nextlargerElement(nums, n);
List<Integer> ans = new ArrayList<>();
for( int i = 0 ;i < n; i++) {
if( fst[i] == -1 || scnd[i] == -1) {
continue;
}
if( fst[i]-i >= k && i - scnd[i] >= k) {
ans.add(i);
}
}
return ans;
}
public static int[] nextLargerElement(int[] arr, int n) {
Stack<Integer> stack = new Stack<>();
int rtrn[] = new int[n];
rtrn[n-1] = -1;
stack.push( n-1);
for( int i = n-2 ;i >= 0 ; i--){
int temp = arr[i];
int lol = -1;
while( !stack.isEmpty() && arr[stack.peek()] <= temp){
if(arr[stack.peek()] == temp ) {
lol = stack.peek();
}
stack.pop();
}
if( stack.isEmpty()){
if( lol != -1) {
rtrn[i] = lol;
}
else {
rtrn[i] = -1;
}
}
else{
rtrn[i] = stack.peek();
}
stack.push( i);
}
return rtrn;
}
public static int[] nextlargerElement(int[] arr, int n) {
Stack<Integer> stack = new Stack<>();
int rtrn[] = new int[n];
rtrn[0] = -1;
stack.add( 0);
for( int i = 1 ;i < n ; i++){
int temp = arr[i];
int lol = -1;
while( !stack.isEmpty() && arr[stack.peek()] <= temp){
if(arr[stack.peek()] == temp ) {
lol = stack.peek();
}
stack.pop();
}
if( stack.isEmpty()){
if( lol != -1) {
rtrn[i] = lol;
}
else {
rtrn[i] = -1;
}
}
else{
rtrn[i] = stack.peek();
}
stack.add( i);
}
return rtrn;
}
static void mysort(int[] arr) {
for(int i=0;i<arr.length;i++) {
int rand = (int) (Math.random() * arr.length);
int loc = arr[rand];
arr[rand] = arr[i];
arr[i] = loc;
}
Arrays.sort(arr);
}
static void mySort(long[] arr) {
for(int i=0;i<arr.length;i++) {
int rand = (int) (Math.random() * arr.length);
long loc = arr[rand];
arr[rand] = arr[i];
arr[i] = loc;
}
Arrays.sort(arr);
}
static long gcd(long a, long b)
{
if (a == 0)
return b;
return gcd(b % a, a);
}
static long lcm(long a, long b)
{
return (a / gcd(a, b)) * b;
}
static long rightmostsetbit(long n) {
return n&-n;
}
static long leftmostsetbit(long n)
{
long k = (long)(Math.log(n) / Math.log(2));
return k;
}
static HashMap<Long,Long> primefactor( long n){
HashMap<Long ,Long> hm = new HashMap<>();
long temp = 0;
while( n%2 == 0) {
temp++;
n/=2;
}
if( temp!= 0) {
hm.put( 2L, temp);
}
long c = (long)Math.sqrt(n);
for( long i = 3 ; i <= c ; i+=2) {
temp = 0;
while( n% i == 0) {
temp++;
n/=i;
}
if( temp!= 0) {
hm.put( i, temp);
}
}
if( n!= 1) {
hm.put( n , 1L);
}
return hm;
}
static TreeSet<Long> allfactors(long abs) {
HashMap<Long,Integer> hm = new HashMap<>();
TreeSet<Long> rtrn = new TreeSet<>();
rtrn.add(1L);
for( long i = 2 ;i*i <= abs; i++) {
if( abs% i == 0) {
hm.put( i , 0);
hm.put(abs/i, 0);
}
}
for( long x : hm.keySet()) {
rtrn.add(x);
}
if( abs != 0) {
rtrn.add(abs);
}
return rtrn;
}
public static int[][] prefixsum( int n , int m , int arr[][] ){
int prefixsum[][] = new int[n+1][m+1];
for( int i = 1 ;i <= n ;i++) {
for( int j = 1 ; j<= m ; j++) {
int toadd = 0;
if( arr[i-1][j-1] == 1) {
toadd = 1;
}
prefixsum[i][j] = toadd + prefixsum[i][j-1] + prefixsum[i-1][j] - prefixsum[i-1][j-1];
}
}
return prefixsum;
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 3c35d94023e66b188e83f55c9033cd82 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import com.sun.security.jgss.GSSUtil;
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.util.HashSet;
import java.util.StringTokenizer;
public class cf799 {
static class FastReader{
BufferedReader br;
StringTokenizer st;
public FastReader(){
br=new BufferedReader(new InputStreamReader(System.in));
}
String next(){
while(st==null || !st.hasMoreTokens()){
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt(){
return Integer.parseInt(next());
}
long nextLong(){
return Long.parseLong(next());
}
double nextDouble(){
return Double.parseDouble(next());
}
String nextLine(){
String str="";
try {
str=br.readLine().trim();
} catch (Exception e) {
e.printStackTrace();
}
return str;
}
}
static class FastWriter {
private final BufferedWriter bw;
public FastWriter() {
this.bw = new BufferedWriter(new OutputStreamWriter(System.out));
}
public void print(Object object) throws IOException {
bw.append("" + object);
}
public void println(Object object) throws IOException {
print(object);
bw.append("\n");
}
public void close() throws IOException {
bw.close();
}
}
public static int fast(){
FastReader sc = new FastReader();
return sc.nextInt();
}
static boolean isPrime(int num)
{
if(num<=1)
{
return true;
}
for(int i=2;i*i<=num;i++)
{
if((num%i)==0)
return false;
}
return true;
}
public static void main(String[] args) {
try {
FastReader sc = new FastReader();
FastWriter out = new FastWriter();
int t=sc.nextInt();
while(t-->0) {
int n=sc.nextInt();
int k=sc.nextInt();
if(n==3 && k==3){
System.out.println(2+" "+2);
}
else if(n>3 && k>3){
System.out.println(1+" "+1);
continue;
}else {
boolean temp=false;
if (n == 1) {
System.out.println(1 + " " + n);
temp=true;
} else if (k == 1) {
System.out.println(1 + " " + k);
temp=true;
} else {
if (n == 2) {
if (k <= 3) {
if(k==2){
System.out.println(1 + " " + 1);
}else{
System.out.println(1 + " " + 2);
}
temp=true;
} else {
System.out.println(1 + " " + 1);
temp=true;
}
} else if(k==2){
if (n <= 3) {
if(n==2){
System.out.println(1 + " " + 1);
}else{
System.out.println(2 + " " + 2);
} temp=true;
} else {
System.out.println(1 + " " + 1);
temp=true;
}
}
}
if(!temp){
System.out.println(1+" "+1);
}
}
}
}catch (Exception e) {
return;
}
}
private static void reverse(int[] lowsum) {
for(int i=lowsum.length-1;i>0;i--){
lowsum[i]=lowsum[i-1];
}
lowsum[0]=0;
}
private static void ff(ArrayList<Integer> ar , ArrayList<Integer> ar2) {
for (Integer integer : ar2) {
int count = 0;
int num = integer;
while (num % 2 == 0) {
count++;
num /= 2;
}
ar.add(count);
}
}
static class Pair {
int a;
int b;
Pair(int a, int b) {
this.a = a;
this.b = b;
}
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 67707c6386222d5fe679bf77a0779c70 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | //۰۪۫A۪۫۰۰۪۫B۪۫۰۰۪۫D۪۫۰۰۪۫-۪۫۰۰۪۫A۪۫۰۰۪۫L۪۫۰۰۪۫L۪۫۰۰۪۫A۪۫۰۰۪۫H۪۫۰
import java.util.*;
public class Main {
static Scanner z = new Scanner(System.in);
public static void main(String[] args) {
int N =z.nextInt();
while(N-->0){
int rows=z.nextInt();
int columns=z.nextInt();
System.out.println(((rows/2)+1)+" "+((columns/2)+1));
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 63cc540ab801faf9140f437d6cf81270 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class q1 {
static int[][] possPos = {{-2,-1},{-2,1},{2,-1},{2,1},{-1,-2},{1,-2},{-1,2},{1,2}};
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();
solve(n,m);
}
}
public static void solve(int n,int m){
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
boolean check = false;
for(int k=0;k<8;k++){
int newX = i+possPos[k][0];
int newY = j+possPos[k][1];
if(newX <=n && newY <=m && newX >0 && newY >0){
// System.out.println(i +" "+j +" foo "+newX +" - "+newY);
check = true;
}
}
if(check == false){
System.out.println(i +" "+j);
return;
}
}
}
System.out.println(1 +" "+1);
return;
}
}
| Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 3f07a5491db7fc8acb60190208800c0e | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class ImmobileKnight {
public static void chess(int n, int m) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (i >= 2 && j <= 1) {
continue;
}
if (i >= 1 && j >= 2) {
continue;
}
if (i >= 2 && j <= m - 2) {
continue;
}
if (i >= 1 && j <= m - 3) {
continue;
}
if (i <= n - 3 && j >= 1) {
continue;
}
if (i <= n - 2 && j >= 2) {
continue;
}
if (i <= n - 2 && j <= m - 3) {
continue;
}
if (i <= n - 3 && j <= m - 2) {
continue;
}
System.out.println((i + 1) + " " + (j + 1));
return;
}
}
System.out.println("1" + " " + "1");
}
public static void main(String[] args) {
Scanner w = new Scanner(System.in);
int t = w.nextInt(); //number of test cases
for (int i = 0; i < t; i++) {
int n = w.nextInt();
int m = w.nextInt();
chess(n, m);
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 6632912fb27631229e763b12ae3b9914 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.io.*;
import java.util.*;
public class Codeforces {
public static class fastReader {
BufferedReader br;
StringTokenizer st;
public fastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
public static boolean isPalindrome(String word) {
for (int i = 0; i < word.length() / 2; i++) {
if (word.charAt(i) != word.charAt(word.length() - 1 - i)) {
return false;
}
}
return true;
}
public static fastReader sc = new fastReader();
static class AreaComparator implements Comparator<List<Long>> {
public int compare(List<Long> p1, List<Long> p2) {
if (p1.get(2) > p2.get(2))
return 1;
else
return -1;
}
}
public static void main(String[] args) {
int t = sc.nextInt();
while (t-- > 0) {
solve();
}
}
public static char getChar(int no) {
int val = 96 + no;
return (char) val;
}
static class Pair {
int val;
int ind;
public Pair(int val, int ind) {
this.val = val;
this.ind = ind;
}
}
static class NComparator implements Comparator<Pair> {
@Override
public int compare(Pair o1, Pair o2) {
if (o1.val > o2.val) {
return 1;
} else if (o1.val == o2.val) {
if (o1.ind > o2.ind) {
return 1;
} else
return -1;
}
return -1;
}
}
static class RComparator implements Comparator<Pair> {
@Override
public int compare(Pair o1, Pair o2) {
if (o1.val < o2.val) {
return 1;
} else if (o1.val == o2.val) {
if (o1.ind > o2.ind) {
return 1;
} else
return -1;
}
return -1;
}
}
private static boolean cb(int i, int j, int n, int m) {
if (i >= 1 && i <= n && j >= 1 && j <= m)
return true;
return false;
}
private static boolean check(int i, int j, int n, int m) {
return cb(i - 2, j - 1, n, m) || cb(i - 1, j - 2, n, m) || cb(i - 2, j + 1, n, m) || cb(i - 1, j + 2, n, m)
|| cb(i + 1, j - 2, n, m) || cb(i + 2, j - 1, n, m) || cb(i + 2, j + 1, n, m) || cb(i + 1, j + 2, n, m);
}
public static void solve() {
int n = sc.nextInt();
int m = sc.nextInt();
boolean foundIso = false;
int i = 1, j = 1;
for (i = 1; i <= n;) {
for (j = 1; j <= m;) {
boolean f = check(i, j, n, m);
// System.out.println("for i " + i + " and j " + j + " f is " + f);
if (f == false) {
foundIso = true;
System.out.println(i + " " + j);
// System.out.println("foudn");
break;
}
j++;
}
if (foundIso)
break;
i++;
}
if (!foundIso)
System.out.println("1 1");
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | 1922a765343ebcb41f85a24de021ddb7 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.Scanner;
public class Knights
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
byte t=sc.nextByte();
for(byte l=1; l<=t; l++)
{
int n=sc.nextInt(), m=sc.nextInt();
boolean mobility=false;
for(int i=1; i<=n; i++)
{
for(int j=1; j<=m; j++)
{
if(i+2<=n||i-2>0)
mobility=(j-1)>0||j+1<=m;
else if(i+1<=n||i-1>0)
mobility=(j-2)>0||(j+2)<=m;
if(!mobility)
{
System.out.println(i+" "+j);
break;
}
}
if(!mobility)
break;
}
if(mobility)
System.out.println(n+" "+m);
}
}
} | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output | |
PASSED | ce48654ee5711aa54bec1bfb9a4d40c5 | train_109.jsonl | 1664462100 | There is a chess board of size $$$n \times m$$$. The rows are numbered from $$$1$$$ to $$$n$$$, the columns are numbered from $$$1$$$ to $$$m$$$.Let's call a cell isolated if a knight placed in that cell can't move to any other cell on the board. Recall that a chess knight moves two cells in one direction and one cell in a perpendicular direction: Find any isolated cell on the board. If there are no such cells, print any cell on the board. | 256 megabytes | import java.util.*;
public class codeforces_solution{
public static void main(String []args){
try (var in = new Scanner(System.in)) {
int t = in.nextInt();
while(t-- > 0){
int n=in.nextInt();
int m=in.nextInt();
if(n ==1 || m == 1){
System.out.println((1)+" "+(1));
}else if(n == 2 && m ==2 ){
if(n == 2)System.out.println((1)+" "+(1));
}else if(n==3 || m==3){
System.out.println((2)+" "+(2));
}else{
System.out.println((n/2 +1)+" "+(m/2+1));
}
}
}
}
}
/*
System.out.print();
Collections.sort(stor, (r,l) -> s.charAt(l-1)-s.charAt(r-1));
// to sort numbers aphabetically
*/ | Java | ["3\n\n1 7\n\n8 8\n\n3 3"] | 2 seconds | ["1 7\n7 2\n2 2"] | NoteIn the first testcase, all cells are isolated. A knight can't move from any cell of the board to any other one. Thus, any cell on board is a correct answer.In the second testcase, there are no isolated cells. On a normal chess board, a knight has at least two moves from any cell. Thus, again, any cell is a correct answer.In the third testcase, only the middle cell of the board is isolated. The knight can move freely around the border of the board, but can't escape the middle. | Java 11 | standard input | [
"implementation"
] | e6753e3f71ff13cebc1aaf04d3d2106b | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of testcases. The only line of each testcase contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 8$$$) — the number of rows and columns of the board. | 800 | For each testcase, print two integers — the row and the column of any isolated cell on the board. If there are no such cells, print any cell on the board. | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.