This commit is contained in:
e2hang
2025-08-14 19:48:01 +08:00
parent 5ebd540fa5
commit f40ad1c843
6 changed files with 114 additions and 0 deletions

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View 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;
}