这个代码本地和在线 IDE 样例都跑的过去,但是提交全 RE,不知道是哪里出错了 qwq
# include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
struct reader {
template <typename Type>
reader & operator >> (Type & ret) {
int f = 1; ret = 0; char ch = getchar ();
for (;!isdigit (ch); ch = getchar ()) if (ch == '-') f = -f;
for (; isdigit (ch); ch = getchar ()) ret = (ret * 10) + ch - '0';
ret *= f; return *this;
}
} fin;
int N, Q;
int L, R, id;
struct ListNode {
int val;
ListNode * next, * last;
ListNode () : val (0) {}
} * head, * now, * Lptr, * Rptr, * Qptr, * Empty;
int main () {
fin >> N >> Q; now = head = new ListNode ();
for (int i = 1; i <= N; i++) {
now -> next = new ListNode();
now -> next -> last = now;
now = now -> next; now -> val = i;
} now -> next = (Empty = new ListNode ());
while (Q--) {
fin >> L >> R >> id; Lptr = Rptr = Qptr = head;
for (int i = 1; i <= N; i++) {
if (i <= L) Lptr = Lptr -> next;
if (i <= R) Rptr = Rptr -> next;
if (i <= id) Qptr = Qptr -> next;
if (i > L && i > R && i > id) break;
}
Lptr -> last -> next = Rptr -> next;
Rptr -> next -> last = Lptr -> last;
Rptr -> next = Qptr -> next;
Rptr -> next -> last = Rptr;
Lptr -> last = Qptr;
Qptr -> next = Lptr;
} now = head;
for (int i = 1; i <= 10; i++) printf ("%d\n", (now = now -> next) -> val);
return 0;
}