too few lines是怎么回事,全WA了,太少行
查看原帖
too few lines是怎么回事,全WA了,太少行
684890
Rhss楼主2022/8/17 10:52
#include <bits/stdc++.h>
using namespace std;
int n;
map<string,int> student;
string name;
int grade;
int main(){
	cin>>n;
	int opt;
	int ans = 0;
	while(true){
		cin>>opt;
		if(opt==1){
			cin>>name>>grade;
			if(student[name]==0){
				student[name]=grade;
				ans++;
			}else{
				student[name]=grade;
			}
			cout<<"OK"<<endl;
		}else{
			if(opt==2){
				cin>>name;
				if(student[name]!=0){
					cout<<student[name]<<endl;
				}else{
					cout<<"Not found"<<endl;	
				}
			}else{
				if(opt==3){
					cin>>name;
					if(student[name]==0){
						cout<<"Not found"<<endl;
					}else{
						student.erase(student.find(name));
						ans--;
						cout<<"Deleted successfully"<<endl;
					}
				}else{		
					break;
				}
			}
		}		
	}
	cout<<ans<<endl;
	return 0;
}
2022/8/17 10:52
加载中...