1 solutions

  • 0
    @ 2025-3-3 16:29:40

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    	map<string,string> m;
    	map<string,string>::iterator i;
    	string s1,s2;
    	bool t=0;
        while(1==1){
        	cin>>s1;
        	if(s1=="$"){
        		exit(0);
    		}else if(s1[0]=='#'){
    			s1.erase(s1.begin());
    			m[s1]=s1;
    			s2=s1;
    		}else if(s1[0]=='+'){
    			s1.erase(s1.begin());
    			m[s1]=s2;
    		}else if(s1[0]=='?'){
    			s1.erase(s1.begin());
    			for(i=m.begin();i!=m.end();i++){
    				if(i->second==s1){
    					cout<<i->first<<endl;
    					t=1;
    				}
    			}
    			if(t==0){
    				cout<<"no data"<<endl;
    			}
    		}
    	}
        return 0;
    }
    
    
    • 1

    Information

    ID
    10275
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By