哲哲打游戏
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define x first
#define y second
map<string, int> cnt1;
vector<int> cnt[100010];
int re[110];
int main() {
int n, m;
scanf("%d%d", &n,&m);
for (int i = 1; i <=n; i++)
{
int k;
scanf("%d", &k);
for (int j = 0; j < k; j++)
{
int x;
scanf("%d", &x);
cnt[i].push_back(x);
}
}
int p = 1;
for (int i = 0; i < m; i++)
{
int a, b;
scanf("%d%d", &a, &b);
if (a == 0)
{
p = cnt[p][b - 1];
}
else if (a == 1)
{
re[b] = p;
cout << p;
cout << endl;
}
else
{
p = re[b];
}
}
cout<<p;
}
清点代码库
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define x first
#define y second
map<vector<int>, int> cnt;
vector<pair<int, vector<int>>> ans;
int main() {
int n, m;
scanf_s("%d%d", &n, &m);
for (int i = 0; i<n; i++)
{
vector<int> line;
for (int j = 0; j < m; j++)
{
int a;
scanf_s("%d", &a);
line.push_back(a);
}
cnt[line]++;
}
for (auto& p : cnt)
{
ans.push_back({ -p.second,p.first });
}
sort(ans.begin(), ans.end());
cout << ans.size()<<endl;
for (auto& p : ans)
{
cout << -p.first;
for (auto& k : p.second)
{
cout<<" "<< k;
}
cout << endl;
}
}
悄悄关注
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define x first
#define y second
map<string, int> cnt;
struct node
{
string name;
int num;
}a[100010];
bool cmp(node a,node b)
{
return a.name < b.name;
}
int main() {
int n, m;
cin>>n;
for (int i = 0; i<n; i++)
{
string ss;
cin>>ss;
cnt[ss]++;
}
cin>>m;
double sum=0;
for (int i = 0; i < m; i++)
{
cin>>a[i].name>>a[i].num;
sum += a[i].num;
}
sum = sum * 1.0 / m;
sort(a,a+m,cmp);
int fa = 0;
for (int i = 0; i < m; i++)
{
if (a[i].num > sum && !cnt[a[i].name])
{
fa = 1;
cout << a[i].name;
if (i < m - 1)
cout << endl;
}
}
if (fa == 0)
cout << "Bing Mei You";
}
乘法口诀 2 3 10
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define x first
#define y second
map<string, int> cnt1;
vector<int> cnt[100010];
const int n = 1010;
int re[100010];
int main() {
string a1, a2;int n;
cin >> a1 >> a2 >> n;
int k = 2;
string str = a1 + a2;
int i = 0, j = 1;
while(str.size()<n)
{
str+=to_string(stoi(str.substr(i, 1)) * stoi(str.substr(j, 1)));
i++; j++;
}
for (int i = 0; i < n; i++)
{
cout << str[i];
if (i < n - 1)cout << " ";
}
}
包装机
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define x first
#define y second
map<string, int> cnt1;
vector<int> cnt[100010];
int re[100010];
int main() {
queue<char> qq[110];
stack<char> ss;
char a[1010];
int n, m, ma;
cin >> n >> m >> ma;
for (int i = 1; i <=n; i++)
{
char str[10000];
cin >> str;
for (int j = 0; j <m; j++)
{
qq[i].push(str[j]);
}
}
int x;
while (cin>>x,x!=-1)
{
if (x == 0)
{
if (ss.size())
{
cout << ss.top();
ss.pop();
}
}
if (x > 0)
{
if (ss.size() == ma&&qq[x].size())
{
cout << ss.top();
ss.pop();
}
if (qq[x].size())
{
ss.push(qq[x].front());
qq[x].pop();
}
}
}
}
ABCDdefg
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main() {
int n;
cin >> n;
while (n--)
{
char str[10000];
cin >> str;
int j;
for (j = 1; j < strlen(str); j++)
{
if (str[j] >= 'a' && str[j] <= 'z')
{
if (str[j - 1] >= 'A' && str[j - 1] <= 'Z'&& str[j] != str[j - 1] - 'A' + 'a')
{
cout << "N" << endl;
break;
}
if (str[j - 1] >= 'a' && str[j - 1] <= 'z'&& str[j] != str[j - 1] + 1)
{
cout << "N" << endl;
break;
}
}
if (str[j] >= 'A' && str[j] <= 'Z')
{
if (str[j - 1] >= 'a' && str[j - 1] <= 'z' && str[j] != str[j - 1] - 'a' + 'A')
{
cout << "N" << endl;
break;
}
if (str[j - 1] >= 'A' && str[j - 1] <= 'Z' && str[j] != str[j - 1] + 1)
{
cout << "N" << endl;
break;
}
}
}
if (j >= strlen(str))cout << "Y" << endl;
}
}