08-14-25
This commit is contained in:
		
							
								
								
									
										11
									
								
								Luogu/SmallerSmallerSmaller/P1241 括号序列.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								Luogu/SmallerSmallerSmaller/P1241 括号序列.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <string>
 | 
			
		||||
using namespace std;
 | 
			
		||||
int main(){
 | 
			
		||||
	string n;
 | 
			
		||||
	cin >> n;
 | 
			
		||||
	for(int i = 0; i < n.size(); i++){
 | 
			
		||||
		
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
} 
 | 
			
		||||
							
								
								
									
										22
									
								
								Luogu/SmallerSmallerSmaller/P1996 约瑟夫问题/deque.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								Luogu/SmallerSmallerSmaller/P1996 约瑟夫问题/deque.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <vector>
 | 
			
		||||
using namespace std;
 | 
			
		||||
 | 
			
		||||
int main() {
 | 
			
		||||
    int n, m;
 | 
			
		||||
    cin >> n >> m;
 | 
			
		||||
    vector<int> a;
 | 
			
		||||
    for (int i = 0; i < n; i++) {
 | 
			
		||||
        a.push_back(i + 1);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    int idx = 0;
 | 
			
		||||
    while (!a.empty()) {
 | 
			
		||||
        idx = (idx + m - 1) % a.size();
 | 
			
		||||
        cout << a[idx] << " ";
 | 
			
		||||
        a.erase(a.begin() + idx);
 | 
			
		||||
    }
 | 
			
		||||
    cout << endl;
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										18
									
								
								Luogu/SmallerSmallerSmaller/P3156 【深基15.例1】询问学号/map.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								Luogu/SmallerSmallerSmaller/P3156 【深基15.例1】询问学号/map.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <unordered_map>
 | 
			
		||||
using namespace std;
 | 
			
		||||
int main(){
 | 
			
		||||
	unordered_map<int, int> a;
 | 
			
		||||
	int n, m;
 | 
			
		||||
    cin >> n >> m;
 | 
			
		||||
    int tmp;
 | 
			
		||||
    for(int i = 0; i < n; i++){
 | 
			
		||||
        cin >> tmp;
 | 
			
		||||
        a.emplace(make_pair(i + 1, tmp));
 | 
			
		||||
    }
 | 
			
		||||
    for(int i = 0; i < m; i++){
 | 
			
		||||
        cin >> tmp;
 | 
			
		||||
        cout << a.find(tmp)->second << endl;
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								Luogu/SmallerSmallerSmaller/P3156 【深基15.例1】询问学号/vector.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								Luogu/SmallerSmallerSmaller/P3156 【深基15.例1】询问学号/vector.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
#include <vector>
 | 
			
		||||
#include <iostream>
 | 
			
		||||
using namespace std;
 | 
			
		||||
int main(){
 | 
			
		||||
    int n, m;
 | 
			
		||||
    cin >> n >> m;
 | 
			
		||||
    vector<int> a;
 | 
			
		||||
    int tmp;
 | 
			
		||||
    for(int i = 0; i < n; i++){
 | 
			
		||||
        cin >> tmp;
 | 
			
		||||
        a.push_back(tmp);
 | 
			
		||||
    }
 | 
			
		||||
    for(int i = 0; i < m; i++){
 | 
			
		||||
        cin >> tmp;
 | 
			
		||||
        cout << a[tmp + 1] << endl;
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										45
									
								
								Luogu/SmallerSmallerSmaller/P4715 【深基16.例1】淘汰赛.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								Luogu/SmallerSmallerSmaller/P4715 【深基16.例1】淘汰赛.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,45 @@
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
#include <deque>
 | 
			
		||||
#include <utility>
 | 
			
		||||
using namespace std;
 | 
			
		||||
struct node{
 | 
			
		||||
	int element;
 | 
			
		||||
	node* left;
 | 
			
		||||
	node* right;
 | 
			
		||||
};
 | 
			
		||||
class tree{
 | 
			
		||||
public:
 | 
			
		||||
	node* root;
 | 
			
		||||
	deque<pair<int, int>> player;
 | 
			
		||||
	int playernum;
 | 
			
		||||
	
 | 
			
		||||
	tree(const deque<pair<int, int>>& x): player(x), playernum(player.size()){};
 | 
			
		||||
	pair<int, int> winner(){
 | 
			
		||||
		deque<pair<int, int>> tmp(player);
 | 
			
		||||
		reverse(tmp.begin(), tmp.end());
 | 
			
		||||
		for(int i = 0; i < 2 * playernum - 2; i += 2){
 | 
			
		||||
			pair<int, int> m = tmp[i].second < tmp[i + 1].second ? tmp[i + 1] : tmp[i] ;
 | 
			
		||||
			tmp.push_back(m);
 | 
			
		||||
		}
 | 
			
		||||
		return tmp.back();
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
int main(){
 | 
			
		||||
	deque<pair<int, int>> m1, m2;
 | 
			
		||||
	int n;
 | 
			
		||||
	cin >> n;
 | 
			
		||||
	int tmp;
 | 
			
		||||
	for(int i = 0; i < pow(2, n - 1); i++){
 | 
			
		||||
		cin >> tmp;
 | 
			
		||||
		m1.push_back(make_pair(i + 1, tmp));
 | 
			
		||||
	}
 | 
			
		||||
	for(int i = pow(2, n - 1); i < pow(2, n); i++){
 | 
			
		||||
		cin >> tmp;
 | 
			
		||||
		m2.push_back(make_pair(i + 1, tmp));
 | 
			
		||||
	}
 | 
			
		||||
	tree t1(m1), t2(m2);
 | 
			
		||||
	pair<int, int> m = t1.winner().second > t2.winner().second ? t2.winner() : t1.winner();
 | 
			
		||||
	cout << m.first << endl;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								Luogu/SmallerSmallerSmaller/P4715 【深基16.例1】淘汰赛.exe
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Luogu/SmallerSmallerSmaller/P4715 【深基16.例1】淘汰赛.exe
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user