社区讨论
我为什会超时啊 P5266 【深基17.例6】学籍管理
P5266【深基17.例6】学籍管理参与者 4已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @lo95u9fz
- 此快照首次捕获于
- 2023/10/28 06:03 2 年前
- 此快照最后确认于
- 2023/10/28 06:03 2 年前
CPP
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
const int N=100010;
struct student {
string name;
int score;
};
int sum;
student a[N];
int main() {
int n;
cin>>n;
for(int i=0;i<n;i++) {
int x;
cin>>x;
if(x==1) {
cin>>a[i].name;
sum++;
cin>>a[i].score;
cout<<"OK"<<endl;
}
if(x==2) {
string c;
cin>>c;
for(int j=0;j<n;j++) {
if(a[j].name==c) {cout<<a[j].score<<endl;break;}
if(a[j].name!=c&&n-1==j)cout<<"Not found"<<endl;
}
}
if(x==3) {
string c;
cin>>c;
for(int j=0;j<n;j++) {
if(a[j].name==c) {
cout<<"Deleted successfully"<<endl;
a[j].name="!!!";
sum--;
}
if(j==n-1&&a[i].name==c) {
cout<<"Not found"<<endl;
}
}
}
if(x==4) cout<<sum<<endl;
}
return 0;
}
回复
共 3 条回复,欢迎继续交流。
正在加载回复...