跳到正文

个人记录

hyw

zhunbeihaolema约 1 分钟
原文

这是 2026年10月6日 存档的第 1 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

发布
2026年10月6日
收录
2026年10月6日
更新
2026年11月17日
篇幅
约 1 分钟

版本

  1. v2当前
  2. v1
C++
#include<bits/stdc++.h>
using namespace std;
int n,m,z;
long long a[5001][5001];
int t1[5001],t2[5001];
int x,y;
int main(){
    cin>>n>>m>>z;
    int cnt=1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            a[i][j]=cnt;
            cnt++;
        }
    }
    for(int i=1;i<=n;i++){
        t1[i]=i;
    }
    for(int j=1;j<=m;j++){
        t2[j]=j;
    }
    for(int i=1;i<=z;i++){
        int a,b,c;
        cin>>a>>b>>c;
        if(a==1){
            swap(t1[b],t1[c]);
        }else if(a==2){
            swap(t2[b],t2[c]);
        }
    }
    cin>>x>>y;
    long long r=t1[x];
    long long c=t2[y];
    long long sum=(r-1)*m+c;
    cout<<sum;
}