Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Level 2] In progress #13

Open
wants to merge 32 commits into
base: NamelessOIer-master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a7f271c
完成了SkipList
NamelessOIer Mar 9, 2021
ceabd7f
Update 1.cpp
NamelessOIer Mar 15, 2021
87f38d1
Update 1.cpp
NamelessOIer Mar 15, 2021
d7c9ac2
有时间就去写c++高精度,先写个python求10w位放着
NamelessOIer Mar 16, 2021
0323d59
10秒内100万位
NamelessOIer Mar 16, 2021
c4e0b7f
Add files via upload
NamelessOIer Mar 16, 2021
0a5cecd
又臭又长的失败作(FFT+牛顿迭代法+高斯-勒让德算法)
NamelessOIer Mar 24, 2021
774f119
调用高精库的成功作
NamelessOIer Mar 24, 2021
4066c55
1m to get 10M
NamelessOIer Mar 24, 2021
56bfc62
793s to get 100M
NamelessOIer Mar 24, 2021
2b1a08d
指针版单向链表
NamelessOIer Mar 30, 2021
f8dd477
指针版双向链表
NamelessOIer Mar 30, 2021
fb031fd
指针版双向链表
NamelessOIer Mar 30, 2021
46c6c9d
Create README.md
NamelessOIer Apr 6, 2021
87d5113
多文件版本双向链表
NamelessOIer Apr 6, 2021
7390730
Create README.md
NamelessOIer Apr 20, 2021
23dae9a
New Version
NamelessOIer Apr 20, 2021
09c046d
Update README.md
NamelessOIer Apr 20, 2021
2c83253
Add files via upload
NamelessOIer Apr 27, 2021
30a4cbd
Update README.md
NamelessOIer Apr 27, 2021
0adf05b
Update README.md
NamelessOIer Apr 29, 2021
55b36e3
Update README.md
NamelessOIer Apr 29, 2021
26922cb
Add files via upload
NamelessOIer Jun 10, 2021
a5bd841
Update README.md
NamelessOIer Jun 10, 2021
0fae308
Update README.md
NamelessOIer Jun 10, 2021
94d6f8d
Add files via upload
NamelessOIer Jun 10, 2021
cd76637
Update README.md
NamelessOIer Jun 10, 2021
655303f
Add files via upload
NamelessOIer Jun 10, 2021
0625a4e
Update README.md
NamelessOIer Jun 10, 2021
2c2a82f
Create README.md
NamelessOIer Jun 16, 2021
8c228cd
最终版本上传
NamelessOIer Jun 16, 2021
40b19dc
演示视频上传
NamelessOIer Jun 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions level1/p11_linkedList/List1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
#include<bits/stdc++.h>

using namespace std;

#define gc c=getchar()
#define r(x) read(x)
#define ll long long

template<typename T>
inline void read(T &x){
x=0;T k=1;char gc;
while(!isdigit(c)){if(c=='-')k=-1;gc;}
while(isdigit(c)){x=x*10+c-'0';gc;}x*=k;
}

struct List{
struct Node{
int val;
Node* next;
}*head;

List(){
head = (Node *)malloc(sizeof(Node));
}

inline void append(const int &x){
Node *ptr = head;
while(ptr -> next){
ptr = ptr -> next;
}
ptr -> next = (Node *)malloc(sizeof(Node));
assert(ptr -> next);
ptr -> next -> val = x;
}

inline Node* insert(const int &ID, const int &x){
Node *ptr = head;
for(int i = 1; i < ID; ++i){
if(ptr -> next){
ptr = ptr -> next;
}
else {
return NULL;
}
}
Node *NewNode = (Node *)malloc(sizeof(Node));
assert(NewNode);
NewNode -> val = x;
NewNode -> next = ptr -> next;
return ptr -> next = NewNode;
}

inline Node* find_next(Node *ptr, const int &x){
if(!ptr)return NULL;
while(ptr -> val != x){
if(ptr -> next){
ptr = ptr -> next;
}
else {
return NULL;
}
}
return ptr;
}

inline Node* find(const int &x){
return find_next(head, x);
}

inline void erase(Node *x,Node *y){
x -> next = y -> next;
free(y);
}

inline void erase_val(const int &x){
Node *ptr = head;
while(ptr -> next){
while(ptr -> next && ptr -> next -> val == x){
erase(ptr, ptr -> next);
}
if(ptr -> next){
ptr = ptr -> next;
}
}
}

inline void erase_ID(const int ID){
Node *ptr = head;
for(int i = 1; i < ID; ++i){
if(ptr -> next){
ptr = ptr -> next;
}
else {
return ;
}
}
if(ptr -> next){
erase(ptr, ptr -> next);
}
}

inline void visit(){
Node *ptr = head;
while(ptr -> next){
ptr = ptr -> next;
printf("%d ",ptr -> val);
}
puts("");
}
}List;

int main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
List.append(1);
List.append(2);
List.append(3);
List.append(4);
List.visit();
List.erase_ID(3);
List.visit();
List.append(1);
List.insert(2, 1);
List.visit();
List.erase_val(1);
List.visit();
srand(time(NULL));
const int N = 10;
for(int i = 0; i < N; ++i){
List.append(rand() & 0xffff);
}
List.visit();
for(int i = 0; i < N / 2; ++i){
List.erase_ID(i);
}
List.visit();
for(int i = 0; i < N / 2; ++i){
List.insert(i, rand() & 0xffff);
}
List.visit();
for(int i = 0; i < N / 4; ++i){
List.erase_val(rand() & 0xffff);
}
List.visit();
return 0;
}
184 changes: 184 additions & 0 deletions level1/p11_linkedList/List2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
#include<bits/stdc++.h>

using namespace std;

#define gc c=getchar()
#define r(x) read(x)
#define ll long long

template<typename T>
inline void read(T &x){
x=0;T k=1;char gc;
while(!isdigit(c)){if(c=='-')k=-1;gc;}
while(isdigit(c)){x=x*10+c-'0';gc;}x*=k;
}

struct List{
struct Node{
int val;
Node* next;
Node* prev;
}*head, *tail;

List(){
head = (Node *)malloc(sizeof(Node));
tail = (Node *)malloc(sizeof(Node));
tail -> prev = head;
head -> next = tail;
}

inline void reverse(){
Node *ptr = head;
while(ptr != NULL){
swap(ptr -> prev, ptr -> next);
ptr = ptr -> prev;
}
swap(head, tail);
}

inline Node* push_back(const int &x){
Node *NewNode = (Node *)malloc(sizeof(Node));
assert(NewNode);
NewNode -> prev = tail -> prev;
tail -> prev -> next = NewNode;
NewNode -> next = tail;
tail -> prev = NewNode;
NewNode -> val = x;
return NewNode;
}

inline Node* push_front(const int &x){
Node *NewNode = (Node *)malloc(sizeof(Node));
assert(NewNode);
NewNode -> next = head -> next;
head -> next -> prev = NewNode;
NewNode -> prev = head;
head -> next = NewNode;
NewNode -> val = x;
return NewNode;
}

inline void erase(Node *x){
x -> prev -> next = x -> next;
x -> next -> prev = x -> prev;
free(x);
}

inline void pop_back(){
if(tail -> prev != head)erase(tail -> prev);
}

inline void pop_front(){
if(head -> next != tail)erase(head -> next);
}

inline Node* insert(const int &ID, const int &x){
if(ID <= 0)return NULL;
Node *ptr = head;
for(int i = 0; i < ID; ++i){
if(ptr -> next){
ptr = ptr -> next;
}
else {
return NULL;
}
}
Node *NewNode = (Node *)malloc(sizeof(Node));
assert(NewNode);
NewNode -> val = x;
ptr -> prev -> next = NewNode;
NewNode -> prev = ptr -> prev;
NewNode -> next = ptr;
ptr -> prev = NewNode;
return NewNode;
}

inline Node* find_next(Node *ptr, const int &x){
if(ptr == tail || !ptr)return NULL;
while(ptr -> val != x){
if(ptr -> next != tail){
ptr = ptr -> next;
}
else return NULL;
}
return ptr;
}

inline Node* find_prev(Node *ptr, const int &x){
if(ptr == head || !ptr)return NULL;
while(ptr -> val != x){
if(ptr -> prev != head){
ptr = ptr -> prev;
}
else return NULL;
}
return ptr;
}

inline Node* find_front(const int &x){
return find_next(head, x);
}

inline Node* find_back(const int &x){
return find_prev(tail, x);
}

inline void erase_val(const int &x){
Node *ptr = head -> next;
while(ptr != tail){
Node *next = ptr -> next;
if(ptr -> val == x){
erase(ptr);
}
ptr = next;
}
}

inline void erase_ID(const int ID){
if(ID <= 0)return ;
Node *ptr = head;
for(int i = 0; i < ID; ++i){
if(ptr -> next != tail){
ptr = ptr -> next;
}
else {
return ;
}
}
erase(ptr);
}

inline void visit(){
Node *ptr = head -> next;
while(ptr != tail){
printf("%d ",ptr -> val);
ptr = ptr -> next;
}
puts("");
}

}List;

int main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
List.push_back(3);
List.push_back(4);
List.push_front(2);
List.push_front(1);
List.visit();
List.erase_ID(3);
List.visit();
List.push_back(1);
List.insert(2, 1);
List.insert(4, 2);
List.visit();
List.reverse();
List.visit();
List.pop_back();
List.pop_front();
List.visit();
List.erase_val(2);
List.visit();
return 0;
}
Loading