【PAT甲级】1133 Splitting A Linked List (25分) 题意: 输入一个五位非负整数S,一个正整数N(<=100000,一个正整数K(1000),接着输入N行数据,每行包括一个结点的地址,结点的数据,下一个结点的地址(地址为五位非负数,数据为整数),输出处理后的顺序,处理过程为先把所有负的结点筛选出来以原本前后顺序排在链表...
#include<iostream>#include<vector>usingnamespacestd;structnode{intdata, id, next; }ans[100010];intmain(){intfid, n, k; vector<node> temp, v;scanf("%d%d%d", &fid, &n, &k);for(inti =0; i < n; i++){ints, d, e;scanf("%d%d%d", &s, &d, &e); ans[s] = {d, s, ...
Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-negatives, and all the values in [0, K] appear before all those greater than K. The order of the elements inside each class must not be changed. For exa...
代码 #include<bits/stdc++.h>using namespace std;constintmaxn=100002;structnode{intdata;intnext;}Node[maxn];structnewnode{intaddr;intdata;newnode(inta,intd):addr(a),data(d){}};vector<newnode>ori,aft;intfir,n,k;intmain(){cin>>fir>>n>>k;for(inti=0;i<n;i++){intaddr;cin>>add...
1133 Splitting A Linked List (25分) 题目地址Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-negatives, and all the values in [0, K] appear before all those greater than K. The order of the elements ...
Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-negatives, and all the values in [0, K] appear before all those greater than K. The order of the elements inside each class must not be changed. For exa...
代码: #include<iostream>usingnamespacestd; pair<int,int> p[100000];boolisf=true;voidprint(intadd,intdata){if(isf){printf("%05d %d ",add,data); isf=false; }elseprintf("%05d\n%05d %d ",add,add,data); }intmain(){intfadd,n,k,add,data,next;scanf("%d%d%d",&fadd,&n,&k);for(...
Splitting A Linked List PAT-1133 本题一开始我是完全按照构建链表的数据结构来模拟的,后来发现可以完全使用两个vector来解决 一个重要的性质就是位置是相对不变的。 #include<iostream> #include<cstring> #i
// Problem: PAT Advanced 1133 // URL: https://pintia.cn/problem-sets/994805342720868352/problems/994805346776760320 // Tags: Linked List #include <iostream> #include <vector> using namespace std; struct ListNode{ int val; int next; }; ListNode list[int(1e5) + 10]; vector<int> parts[3...
1133 Splitting A Linked List (25 分) Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-negatives, and all the values in [0, K] appear before all those greater than K. The order of the elements inside ...