Codeforces Round 959 sponsored by NEAR (Div. 1 + Div. 2)解题报告(A-C)

Codeforces Round 959 sponsored by NEAR (Div. 1 + Div. 2)解题报告(A-C)

A. Diverse Game

链接: A. Diverse Game
在这里插入图片描述

题目大意:将所给矩阵进行变换为一个与原矩阵不同的矩阵

解题思路:每个值都右移一位,如果每行都只有一个值,则每个值都下移一位

个人代码:

#include <bits/stdc++.h>

using namespace std;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(n+1, vector<int> (m+1, -1));
    vector<vector<int>> b(n+1, vector<int> (m+1, -1));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> a[i][j];
            // if (i == n && j == n) b[i][j] = a[1][1];
            // else if (i == n) b[i][j] = a[1][j];
            // else if (j == m) b[i][j] = a[i][1];
        }
    }
    if (n == 1 && m == 1) cout << -1 << endl;
    else if (n == 1){
        for (int i = 1; i < m; i++) {
            cout << a[1][i+1] << ' ';
        }
        cout << a[1][1] << endl;
    } else if (m == 1) {
        for (int i = 1; i < n; i++) {
            cout << a[i+1][1] << endl;
        }
        cout << a[1][1] << endl;
    } else {
        for (int i = 1; i <
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值