其实这题也挺简单hh
#include <bits/stdc++.h>
using namespace std;
int s[600010];
int l = 300001, r = 300000, n;
char c; int x;
int main() {
cin >> n;
while (n--) {
cin >> c >> x;
if(c == 'L') s[x] = --l;
else if(c == 'R') s[x]= ++r;
else cout << min(abs(s[x] - l), abs(s[x] - r)) << endl;
}
return 0;
}
大佬,为啥l,r初始l比r大1??