Please sign in first.
Submission #44889961
Source Code Expand
#include <iostream>
using namespace std;
long long n, q, m[1000001], a, b;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> n >> q;
for(long long i = 1; i <= n; i++) m[i] = n * (i - 1);
for(long long i = n + 1; i <= 2 * n; i++) m[i] = i - 1 - n;
a = 0, b = n;
for(long long i = 1; i <= q; i++){
long long option;
cin >> option;
if(option == 1){
long long x, y;
cin >> x >> y;
swap(m[a + x], m[a + y]);
}
else if(option == 2){
long long x, y;
cin >> x >> y;
swap(m[b + x], m[b + y]);
}
else if(option == 3) swap(a, b);
else{
long long x, y;
cin >> x >> y;
long long ans = m[a + x] + m[b + y];
cout << ans << endl;
}
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | I - Matrix Operations |
| User | NFGase |
| Language | C++ (GCC 9.2.1) |
| Score | 6 |
| Code Size | 920 Byte |
| Status | AC |
| Exec Time | 69 ms |
| Memory | 5132 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 6 / 6 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample0.txt, sample1.txt |
| All | large0.txt, large1.txt, large2.txt, large3.txt, large4.txt, large5.txt, sample0.txt, sample1.txt, small1.txt, small2.txt, small3.txt, small4.txt, small5.txt, small6.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| large0.txt | AC | 69 ms | 5092 KiB |
| large1.txt | AC | 63 ms | 5064 KiB |
| large2.txt | AC | 63 ms | 5100 KiB |
| large3.txt | AC | 62 ms | 5132 KiB |
| large4.txt | AC | 63 ms | 5068 KiB |
| large5.txt | AC | 64 ms | 5040 KiB |
| sample0.txt | AC | 6 ms | 3500 KiB |
| sample1.txt | AC | 2 ms | 3460 KiB |
| small1.txt | AC | 61 ms | 3540 KiB |
| small2.txt | AC | 57 ms | 3508 KiB |
| small3.txt | AC | 57 ms | 3608 KiB |
| small4.txt | AC | 58 ms | 3536 KiB |
| small5.txt | AC | 60 ms | 3612 KiB |
| small6.txt | AC | 60 ms | 3628 KiB |