社区讨论

样例过了,但是全WA,求大佬调代码

P5266【深基17.例6】学籍管理参与者 3已保存回复 4

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
4 条
当前快照
1 份
快照标识符
@lo2xu2uu
此快照首次捕获于
2023/10/23 21:33
2 年前
此快照最后确认于
2023/10/23 21:33
2 年前
查看原帖
CPP
#include<bits/stdc++.h>
using namespace std;
map<string,int> m;
int n;
int k,j;
int ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>k;
		string temp1;
		int score;
		if(k==1){
			cin>>temp1>>score;
			if(!m[temp1]){
				cout<<"OK"<<endl;
				ans++;
			}
			m[temp1]=score;
		}
		else if(k==2){
			cin>>temp1;
			if(!m[temp1]){
				cout<<"Not found"<<endl;
			}
			else cout<<m[temp1]<<endl;
		}
		else if(k==3){
			cin>>temp1;
			if(!m[temp1]){
				cout<<"Not found";
			}
			else {
				m[temp1]=0;
				ans--;
				cout<<"Deleted successfully"<<endl;
			}
		}
		else cout<<ans<<endl;
	}
	return 0;
} 

回复

4 条回复,欢迎继续交流。

正在加载回复...