今天晚上at,同学C题++cntWA了,但只有C++20会WA,C++17AC,是有什么新语法吗?
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e7 + 10;
int cnt = 1;
pair<int, int>a[N];
signed main() {
int n, m;
cin >> n >> m;
a[1].first = 1, a[1].second = 0;
while(m--) {
int op;
cin >> op;
if(op == 1) {
char dir;
cin >> dir;
if(dir == 'U') a[++cnt].first = a[cnt - 1].first, a[cnt].second = a[cnt - 1].second + 1;
if(dir == 'D') a[++cnt].first = a[cnt - 1].first, a[cnt].second = a[cnt - 1].second - 1;
if(dir == 'L') a[++cnt].first = a[cnt - 1].first - 1, a[cnt].second = a[cnt - 1].second;
if(dir == 'R') a[++cnt].first = a[cnt - 1].first + 1, a[cnt].second = a[cnt - 1].second;
}
else {
int p;
cin >> p;
if(p - 1 > (cnt - 1)) {
cout << p - cnt + 1 << " " << 0 << endl;
}
else {
int now = cnt - (p - 1);
//cout << now << endl;
cout << a[now].first << " " << a[now].second << endl;
}
}
}
}