首页 > 试题广场 >

二维数组操作

[编程题]二维数组操作
  • 热度指数:92234 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32M,其他语言64M
  • 算法知识视频讲解
有一个大小的数据表,你会依次进行以下5种操作:
1.输入,初始化大小的表格。
2.输入x_1y_1x_2y_2,交换坐标在(x_1,y_1)(x_2,y_2)的两个数。
3.输入,在第上方添加一行。
4.输入,在第左边添加一列。
5.输入,查找坐标为的单元格的值。

请编写程序,判断对表格的各种操作是否合法。

详细要求:

1.数据表的最大规格为9行*9列,对表格进行操作时遇到超出规格应该返回错误。
2.对于插入操作,如果插入后行数或列数超过9了则应返回错误。如果插入成功了则将数据表恢复至初始化的大小,多出的数据则应舍弃。

3.所有输入坐标操作,对大小的表格,行号坐标只允许0~m-1,列号坐标只允许0~n-1。超出范围应该返回错误。

本题含有多组样例输入!行列从0开始标号
数据范围:数据组数:
进阶:时间复杂度:,空间复杂度:

输入描述:

输入数据按下列顺序输入:
1 表格的行列值
2 要交换的两个单元格的行列值
3 输入要插入的行的数值
4 输入要插入的列的数值
5 输入要查询的单元格的坐标



输出描述:

输出按下列顺序输出:
1 初始化表格是否成功,若成功则返回0, 否则返回-1
2 输出交换单元格是否成功
3 输出插入行是否成功
4 输出插入列是否成功
5 输出查询单元格数据是否成功

示例1

输入

4 9
5 1 2 6
0
8
2 3
4 7
4 2 3 2
3
3
4 7

输出

0
-1
0
-1
0
0
-1
0
0
-1

说明

本组样例共有2组样例输入。
第一组样例:
1.初始化数据表为4行9列,成功
2.交换第5行1列和第2行6列的数据,失败。因为行的范围应该是(0,3),不存在第5行。
3.在第0行上方添加一行,成功。
4.在第8列左边添加一列,失败。因为列的总数已经达到了9的上限。
5.查询第2行第3列的值,成功。
第二组样例:
1.初始化数据表为4行7列,成功
2.交换第4行2列和第3行2列的数据,失败。因为行的范围应该是(0,3),不存在第4行。
3.在第3行上方添加一行,成功。
4.在第3列左边添加一列,成功。
5.查询第4行7列的值,失败。因为虽然添加了一行一列,但数据表会在添加后恢复成4行7列的形态,所以行的区间仍然在[0,3],列的区间仍然在[0,6],无法查询到(4,7)坐标。       
while True:
    try:
        m,n=list(map(int,input().split()))
        exchange=list(map(int,input().split()))
        insertrow=int(input())
        insertcol=int(input())
        trace=list(map(int,input().split()))
        res=[]
        if 0<=m<=9 and 0<=n<=9:
            res.append(0)
        else:
            res.append(-1)
        if 0<=exchange[0]<=m-1 and 0<=exchange[1]<=n-1 and 0<=exchange[2]<=m-1 and 0<=exchange[3]<=n-1:
            res.append(0)
        else:
            res.append(-1)
        if 0<=insertrow<=m-1:
            res.append(0)
        else:
            res.append(-1)
            
        if 0<=insertcol<=n-1:
            res.append(0)
        else:
            res.append(-1)
            
        if 0<=trace[0]<=m-1 and 0<=trace[1]<=n-1:
            res.append(0)
        else:
            res.append(-1)
            
        for i in res:
            print(i)
    except:
        break

发表于 2019-10-20 23:12:48 回复(1)
import java.util.Scanner;

public class Main {
	
    public static void main(String[] args) {
    	
        Scanner in = new Scanner(System.in);
        
        while (in.hasNextInt()) {
        	int n = in.nextInt();
        	int m = in.nextInt();
        	if(n > 9 || m > 9 || n < 0 || m < 0) {
        		System.out.println(-1);
        	} else {
        		System.out.println(0);
        	}
        	int ax = in.nextInt();
        	int ay = in.nextInt();
        	int bx = in.nextInt();
        	int by = in.nextInt();
        	if(ax >= n || ay >= m || ax < 0 || ay < 0 || bx >= n || by >= m || bx < 0 || by < 0) {
        		System.out.println(-1);
        	} else {
        		System.out.println(0);
        	}
        	int addx = in.nextInt();
        	if(addx >= n || addx < 0) {
        		System.out.println(-1);
        	} else {
        		System.out.println(0);
        	}
        	int addy = in.nextInt();
        	if(addy >= m || addy < 0) {
        		System.out.println(-1);
        	} else {
        		System.out.println(0);
        	}
        	int sx = in.nextInt();
        	int sy = in.nextInt();
        	if(sx >= n || sy >= m || sx < 0 || sy < 0) {
        		System.out.println(-1);
        	} else {
        		System.out.println(0);
        	}
        }
        
        in.close();
    }
}

真的好难看懂。。。。。

发表于 2016-08-24 13:15:23 回复(0)
#include<iostream>
using namespace std;

void out(bool flag) {
    cout << (flag ? "0" : "-1") << endl;
}

int main() {
    int m, n, i, j, x, y;
    while (cin >> m >> n) {
        --m, --n;
        out(0 <= m && m <= 8 && 0 <= n && n <= 8);

        cin >> i >> j >> x >> y;
        out(0 <= i && i <= m && 0 <= j && j <= n 
           && 0 <= x && x <= m && 0 <= y && y <= n);

        cin >> i >> j;
        out(0 <= i && i <= m && m < 8);
        out(0 <= j && j <= n && n < 8);

        cin >> i >> j;
        out(0 <= i && i <= m && 0 <= j && j <= n);
    }
    
    return 0;
}

发表于 2022-08-05 15:38:20 回复(0)
题目是很长,而且解释有问题,给的是坐标而不是第几行第几列,比如(3,2)是第四行第三列,毕竟是数组。其实一步一步做下来就是很简单的判断,我的代码为了省事少了一些负数的校验,不过通过用例是没问题的
while True:
    try:
        m,n=map(int, input().split())
        #1
        if m<0&nbs***bsp;m>9&nbs***bsp;n<0&nbs***bsp;n>9:
            print(-1)
        else:
            print(0)
        h1,l1,h2,l2=map(int, input().split())
        #2
        if h1>=m&nbs***bsp;h2>=m&nbs***bsp;l1>=n&nbs***bsp;l2>=n:
            print(-1)
        else:
            print(0)
        #3
        shang=int(input())
        if shang>=0 and shang<=m and m!=9:
            print(0)
        else:
            print(-1)
        #4
        zuo = int(input())
        if zuo>=0 and zuo<n and n!=9:
            print(0)
        else:
            print(-1)
        #5
        x,y=map(int, input().split())
        if x>=m&nbs***bsp;y>=n:
            print(-1)
        else:
            print(0)    
    except:
        break


发表于 2022-07-03 16:51:39 回复(0)
这题目意义不明啊,而且好像并不会出现初始化失败的情况,虽然题目也没说初始化失败应该怎么办
import java.util.Scanner;

public class Main{
    public static int m,n;
    public static boolean isInitialFlag;
    
    public static int initialize(int m, int n){
        if(m<=9 && n<=9){
            isInitialFlag = true;
            return 0;
        }
        else{
            isInitialFlag = false;
            return -1;
        }
    }
    
    public static int exchange(int x1, int y1, int x2, int y2){
        if(x1<m && x2<m && y1<n && y2<n) return 0;
        else return -1;
    }
    
    public static int insertLine(int line){
        if(m<9 && line<m) return 0;
        else return -1;
    }
    
    public static int insertCol(int col){
        if(n<9 && col<n) return 0;
        else return -1;
    }
    public static int enquire(int x, int y){
        if(x>=0 && x<m && y>=0 && y<n) return 0;
        else return -1;
    }
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            m = sc.nextInt();
            n = sc.nextInt(); 
            isInitialFlag = true;// 初始化
            int x1 = sc.nextInt();
            int y1 = sc.nextInt();
            int x2 = sc.nextInt();
            int y2 = sc.nextInt(); // 交换
            int line = sc.nextInt(); // 插入行
            int col = sc.nextInt(); // 插入列
            int x = sc.nextInt();
            int y = sc.nextInt(); // 查询
            
            System.out.println(initialize(m,n));
            System.out.println(exchange(x1, y1, x2, y2));
            System.out.println(insertLine(line));
            System.out.println(insertCol(col));
            System.out.println(enquire(x, y));
            
        }
    }
}

发表于 2022-04-22 08:11:21 回复(1)
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int m,n,x1,y1,x2,y2,row,col,x,y;
    while(cin>>m>>n>>x1>>y1>>x2>>y2>>row>>col>>x>>y)
    {
        if(m>9||n>9)
            cout << -1 << endl;
        else
            cout << 0 << endl;
        if(x1>=0&&x1<m&&y1>=0&&y1<n&&x2>=0&&x2<m&&y2>=0&&y2<n)
            cout << 0 << endl;
        else
            cout << -1 << endl;
        if(m<9&&row>=0&&row<=m-1)
            cout << 0 << endl;
        else
            cout << -1 << endl;
        if(n<9&&col>=0&&col<=n-1)
            cout << 0 << endl;
        else
            cout << -1 << endl;
        if(x>=0&&x<=m-1&&y>=0&&y<=n-1)
            cout << 0 << endl;
        else
            cout << -1 << endl;
    }
    
    return 0;
}

发表于 2021-07-30 15:19:50 回复(1)
#include <iostream>
#include <vector>
using namespace std;

int main() 
{
	int m,n;
	while(cin>>m>>n)
	{
		if ((m>9)||(n>9))
		{
			cout<< -1 <<endl;
		}
		else
		{
			cout<< 0 <<endl;
		}

		vector<vector<int>>  matrix(m, vector<int>(n,0));

		int x1,x2,y1,y2;
		cin >> x1 >> y1 >> x2 >> y2;

		if ((x1>=m)||(x2>=m)||(y1>=n)||(y2>=n))
		{
			cout<< -1 <<endl;
		}
		else
		{
			cout<< 0 <<endl;

			int temp = matrix[x1][y1];
			matrix[x1][y1] = matrix[x2][y2];
			matrix[x2][y2] = temp;
		}


		//插入行
		int x_inster;
		cin >> x_inster;
		if (((m+1)>9)||(x_inster >= m))
		{ 
			cout<< -1 <<endl;
		}
		else
		{
			cout<< 0 <<endl;

			vector<int> line(n,0);
			matrix.insert(matrix.begin()+x_inster, line);
			matrix.pop_back();
		}



		//插入列
		int  y_inster;
		cin >> y_inster;
		if (((n+1)>9)||(y_inster >= n))
		{ 
			cout<< -1 <<endl;
		}
		else
		{
			cout<< 0 <<endl;

			for (int irow=0; irow<m; irow++)
			{
				matrix[irow].insert(matrix[irow].begin()+ y_inster, 0);
				matrix[irow].pop_back();
			}
		}

		int x_val,y_val;
		cin >> x_val >> y_val;

		if ((x_val>=m)||(y_val>=n))
		{
			cout << -1 <<endl;
		}
		else
		{
			cout << 0 <<endl;
		}

	}
    return 0;
}

发表于 2021-04-18 11:39:01 回复(0)
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            int[] feedbacks = new int[5];
            String[] size = scanner.nextLine().split(" ");
            feedbacks[0] = (Integer.parseInt(size[0]) > 9 || Integer.parseInt(size[1]) > 9) ? -1 : 0;
            String[] twoCoordinate = scanner.nextLine().split(" ");
            feedbacks[1] = (Integer.parseInt(twoCoordinate[0]) >= Integer.parseInt(size[0]) || Integer.parseInt(twoCoordinate[1]) >= Integer.parseInt(size[1]) || Integer.parseInt(twoCoordinate[2]) >= Integer.parseInt(size[0]) || Integer.parseInt(twoCoordinate[3]) >= Integer.parseInt(size[1])) ? -1 : 0;
            int rowInsert = Integer.parseInt(scanner.nextLine());
            feedbacks[2] = (rowInsert >= Integer.parseInt(size[0]) || Integer.parseInt(size[0]) == 9) ? -1 : 0;
            int colInsert = Integer.parseInt(scanner.nextLine());
            feedbacks[3] = (colInsert >= Integer.parseInt(size[1]) || Integer.parseInt(size[1]) == 9) ? -1 : 0;
            String[] searchCoor = scanner.nextLine().split(" ");
            feedbacks[4] = (Integer.parseInt(searchCoor[0]) >= Integer.parseInt(size[0]) || Integer.parseInt(searchCoor[1]) >= Integer.parseInt(size[1])) ? -1 : 0;
            for (int i : feedbacks){
                System.out.println(i);
            }
        }
    }
}

发表于 2021-02-16 17:11:59 回复(0)
1、示例有问题, 1 1 0 1应该在一行;
2、初始化形成表格时,数字代表行、列的数量,后面的所有操作需要以0为初始索引计算,特别注意边界问题,否则会出错。
while True:
    try:
        rowLength, columnLength = list(map(int, input().split()))
        if 0 < rowLength <= 9 and 0 < columnLength <= 9:
            print(0)
        else:
            print(-1)
        rowMove1, columnMove1, rowMove2, columnMove2 = list(map(int, input().split()))
        if 0 <= rowMove1 < rowLength and 0 <= columnMove1 < columnLength and 0 <= rowMove2 < rowLength and 0 <= columnMove2 < columnLength:
            print(0)
        else:
            print(-1)
        rowInsert = int(input())
        if 0 <= rowInsert < rowLength and rowLength < 9:
            print(0)
        else:
            print(-1)
        columnInset = int(input())
        if 0 <= columnInset < columnLength and columnLength < 9:
            print(0)
        else:
            print(-1)
        rowSearch, columnSearch = list(map(int, input().split()))
        if 0 <= rowSearch < rowLength and 0 <= columnSearch < columnLength:
            print(0)
        else:
            print(-1)
    except EOFError:
        break


发表于 2020-10-01 23:34:52 回复(0)
#include <bits/stdc++.h>
using namespace std;

// 不知道题在说什么,看着别人的代码想的

int main(){
    int row,col;
    int dp[9][9]={0};
    while(cin >> row >> col){
        int res[5]={0};
        if(row <=0 || col <= 0) res[0] = -1;
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        if(a < 0 || a >= row || c <0 || c >= row || b <0 || b >= col || d<0 || d >=col) res[1] = -1;;
        int e,f;
        cin >> e >> f;
        if(e<0 || e>=row) res[2] = -1;
        if(f<0 || f>=col) res[3] = -1;
        int m,n;
        cin >> m >> n;
        if(m<0 || m >= row || n<0 || n >= col) res[4] = -1;
        for(int i=0; i<5; i++){
            cout << res[i] << endl;
        }
    }
      
}

发表于 2018-08-07 11:09:59 回复(1)
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <cctype>
#include <vector>

using namespace std;

int main()
{     int n,m;     while(cin>>n>>m)     {         if(n>9 || m>9)              cout<<-1<<endl;         else             cout<<0<<endl;                      int a,b,c,d;         cin>>a>>b>>c>>d;         if(a<0 || a>=n || b<0 || b>=m || c<0 || c>=n || d<0 || d>=m)             cout<<-1<<endl;         else             cout<<0<<endl;                  cin>>a;         if(a<0 || a>=n)             cout<<-1<<endl;         else             cout<<0<<endl;                  cin>>b;         if(b<0 || b>=m)             cout<<-1<<endl;         else             cout<<0<<endl;                  cin>>a>>b;         if(a<0 || a>=n || b<0 || b>=m)             cout<<-1<<endl;         else             cout<<0<<endl;     }     return 0;
}

发表于 2018-05-30 01:34:14 回复(0)
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int m,n,row,colum;
    while(cin>>m>>n){
        int posa[2],posb[2];
        cin>>posa[0]>>posa[1];
        cin>>posb[0]>>posb[1];
        if(m<0||m>9||n<0||n>9)
            cout<<-1<<endl;
        else
            cout<<0<<endl;
        if(posa[0]>=0&&posa[0]<m&&posa[1]>=0&&posa[1]<n&&posb[0]>=0&&posb[0]<m&&posb[1]>=0&&posb[1]<n)
            cout<<0<<endl;
        else
            cout<<-1<<endl;
     	cin>>row;
        if(row<0||row>=m)
            cout<<-1<<endl;
     	else{
            cout<<0<<endl;
          //  m+=1;
        }
        cin>>colum;
        if(colum<0||colum>=n)
            cout<<-1<<endl;
     	else{
            cout<<0<<endl;
           // n+=1;
        }
        cin>>row>>colum;
        if(row>=0&&row<m&&colum>=0&&colum<n)
            cout<<0<<endl;
        else
            cout<<-1<<endl;
        
    }
    return 0;
}
看懂的难度大于题目本身,那位童鞋说的精辟。。。。

发表于 2016-08-10 20:43:33 回复(1)
题目在说啥?
发表于 2016-09-03 14:44:37 回复(35)
我只能从通过代码中推出题目意思。。。
编辑于 2017-07-16 22:01:25 回复(7)
建议兄弟们集美们直接跳过!
发表于 2020-06-14 17:27:58 回复(0)
题目看懂的难度大于程序本身。
#include <stdio.h>
#include <vector>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
   int h;int l;
    while(cin>>h>>l)
    {
        if(h>9||l>9)  cout<<"-1"<<endl;
        else cout<<"0"<<endl;
        int c1h,c1l,c2h,c2l;
        cin>>c1h>>c1l>>c2h>>c2l;
        if(c1h>=0 && c1h<h && c1l>=0 && c1l<l && c2h>=0 && c2h<h &&c2l>=0 && c2l<l )
            cout<<"0"<<endl;
        else cout<<"-1"<<endl;
        int d,e;cin>>d>>e;
        if(d>=0 && d<h) cout<<"0"<<endl;
        else cout<<"-1"<<endl;
         if(e>=0 && e<l) cout<<"0"<<endl;
        else cout<<"-1"<<endl;
        int m,n;
        cin>>m>>n;
        if(m>=0 &&m<h && n>=0 && n<l)
            cout<<"0"<<endl;
        else cout<<"-1"<<endl;
    }
}

发表于 2016-07-14 15:22:22 回复(6)
这题目是开玩笑吧
发表于 2017-06-30 09:44:32 回复(1)
乍一看,题目挺繁琐,实际上就是纸老虎,就是检查每个输入参数是否超出给定范围,是就输出-1,否就输出0
#include <iostream>
using namespace std;
int main(){
   int r, c,r1,c1,r2,c2,ri,ci,rt,ct;
    while(cin>>r>>c>>r1>>c1>>r2>>c2>>ri>>ci>>rt>>ct)
    {
        if(r>9||c>9)  cout<<"-1"<<endl;
        else cout<<"0"<<endl;
        
        if(r1>=0 && r1<r && c1>=0 && c1<c && r2>=0 && r2<r && c2>=0 && c2<c) cout<<"0"<<endl;       
        else cout<<"-1"<<endl;
        
        if(ri>=0 && ri<r) cout<<"0"<<endl;
        else cout<<"-1"<<endl;
        
        if(ci>=0 && ci<c) cout<<"0"<<endl;
        else cout<<"-1"<<endl;
        
        if(rt>=0 && rt<r && ct>=0 && ct<c) cout<<"0"<<endl;   
        else cout<<"-1"<<endl;
    }
}

发表于 2018-06-26 10:30:55 回复(5)
除了繁还是繁
#include <algorithm>
#include <iostream>

using namespace std;

struct Point
{
    int x, y;
    Point(){}
    Point(int x, int y) : x(x), y(y){}
};

struct Info
{
    int x, y;
    vector<Point> change;
    Info(){}
    Info(int x, int y) : x(x), y(y){}
};


bool initial(vector<vector<Info>> & table)
{
    int row = table.size(), col = table[0].size();
    if(row < 0 || row > 9 || col < 0 || col > 9) return false;

    table.resize(row);
    for(int i = 0; i < row; i++)
    {
        table[i].resize(col);
        for (int j = 0; j < col; j++)
        {
            table[i][j] = Info(i, j);
            table[i][j].change.push_back(Point(i, j));
        }
    }
    return true;
}

bool exchange(vector<vector<Info>> & table)
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if(x1 < 0 || x1 >= table.size() || y1 < 0 || y1 >= table[0].size() ||
       x2 < 0 || x2 >= table.size() || y2 < 0 || y2 >= table[0].size()) return false;

    Info temp = table[x1][y1];
    table[x1][y1] = table[x2][y2];
    table[x2][y2] = temp;

    table[x1][y1].change.push_back(Point(x1, y1));
    table[x2][y2].change.push_back(Point(x2, y2));
    return true;
}

bool insertROW(vector<vector<Info>> & table)
{
    int row; cin >> row;
    if(row < 0 || row >= table.size()) return false;

    for(int i = row; i < table.size(); i++)
        for(int j = 0; j < table[0].size(); j++)
        {
            int x = table[i][j].x, y = table[i][j].y;
            if(x == 9) return false;
            table[i][j].x++;
            table[i][j].change.push_back(Point(x+1, y));
        }
    return true;
}

bool insertCOL(vector<vector<Info>> & table)
{
    int col; cin >> col;
    if(col < 0 || col >= table[0].size()) return false;

    for(int i = 0; i < table.size(); i++)
        for(int j = col; j < table[0].size(); j++)
        {
            int x = table[i][j].x, y = table[i][j].y;
            if(y == 9) return false;
            table[i][j].y++;
            table[i][j].change.push_back(Point(x, y+1));
        }
    return true;
}

bool quest(vector<vector<Info>> & table)
{
    int row, col;
    cin >> row >> col;
    if(row < 0 || row >= table.size() || col < 0 || col >= table[0].size()) return false;
    return true;
}

void solve(vector<vector<Info>> & table)
{
    int init = initial(table) ? 0 : -1;
    int exchg = init == 0 && exchange(table) ? 0 : -1;
    int insRow = init == 0 && insertROW(table) ? 0 : -1;
    int insCol = init == 0 && insertCOL(table) ? 0 : -1;
    int qust = init == 0 && quest(table) ? 0 : -1;

    cout << init << endl << exchg << endl << insRow << endl << insCol << endl << qust << endl;
}

int main()
{
    int row, col;
    while(cin >> row >> col)
    {
        vector<vector<Info>> table(row, vector<Info>(col));
        solve(table);
    }

    return 0;
} 


编辑于 2016-05-20 21:00:02 回复(2)
"""
根据评论区讨论和样例说明,简单总结下题目要进行的操作:
1,数据表行列范围都是[0,9].
2,交换的坐标行列数要在输入的表格大小行列数范围[0, m)x[0, n)内.
3,插入的 x 位置要在 [0, m) 范围内,插入的 y 位置要在 [0, n) 范围内.
4,要检查的位置 (x,y) 要在 [0, m)x[0, n) 内.

以上条件若满足输出'0',否则输出'-1'
"""

while True:
    try:
        # 数据表大小
        m, n = map(int, input().split())
        # 要交换的两个坐标位置
        x1, y1, x2, y2 = map(int, input().split())
        # 进行插入的行
        insert_x = int(input())
        # 进行插入的列
        insert_y = int(input())
        # 要查找的坐标位置
        x, y = map(int, input().split())
        
        # 1,数据表行列范围都是[0,9],若满足输出'0',否则输出'-1'
        if (0 <= m <= 9) and (0 <= n <= 9):
            print('0')
        else:
            print('-1')
        # 2,交换的坐标行列数要在输入的表格大小行列数范围[0, m)x[0, n)内
        if (0 <= x1 < m) and (0 <= y1 < n) and (0 <= x2 < m) and (0 <= y2 < n):
            print('0')
        else:
            print('-1')
        # 3.1,插入的x坐标要在 [0, m) 范围内
        if (0 <= insert_x < m) and (m < 9):
            print('0')
        else:
            print('-1')
        # 3.2,插入的y坐标要在 [0, n) 范围内
        if (0 <= insert_y < n) and (n < 9):
            print('0')
        else:
            print('-1')
        # 4,要检查的位置 (x,y) 要在 [0, m)x[0, n) 内
        if (0 <= x < m) and (0 <= y < n):
            print('0')
        else:
            print('-1')
    except:
        break
                  

发表于 2020-12-02 12:37:54 回复(0)