8 solutions

  • 3
    @ 2024-1-28 11:20:36
    #include<bits/stdc++.h>
    using namespace std;
    string n;
    int a[1000005];
    int main(){
    	getline(cin,n);
    	for(long long i=0;n[i];i++) a[n[i]-'a']++;
    	for(long long i=0;n[i];i++){
    		if(a[n[i]-97]==1){
    			cout<<n[i];
    			break;
    		}
    		if(n[i+1]==false&&a[n[i]-'a']!=1) cout<<"no";
    	}
    	return 0;
    }
    
    • 3
      @ 2023-10-8 13:15:51
      #include <bits/stdc++.h>
      using namespace std;
      string s;
      int t[26],idx,f[26];
      int main(int argc, char **argv){
      	getline(cin,s);
      	int len = s.length();
      	for(int i = 0;i < len;i++){
      		t[(int)s[i] - 'a']++;
      		if (t[(int)s[i] - 'a'] == 1){
      			f[(int)s[i] - 'a'] = ++idx;
      		}else if (t[(int)s[i] - 'a'] > 1){
      			f[(int)s[i] - 'a'] = 0;
      			for(int j = 0;j < 26;j++){
      				if (f[j] > 1){
      					f[j]--;
      				}
      			}
      		}
      	}
      	for (int i = 0;i < 26;i++){
      		char c = 'a' + i;
      		if (f[i] == 1){
      			cout << c;
      			return 0;
      		}
      	}
      	cout << "no";
      	return 0;
      }
      
      • 2
        @ 2023-9-29 12:02:20

        `

        #include<iostream>
        using namespace std;
        bool visit[30];
        bool flag[30];
        int main()
        {
        	string str;
        	cin >> str;
        	for(int i = 0; i < str.size(); i++)
        	{
        		if(visit[str[i] - 'a'])
        		{
        			flag[str[i] - 'a'] = true;
        		}
        		visit[str[i] - 'a'] = true;
        	}
        	for(int i = 0; i < str.size(); i++)
        	{
        		if(!flag[str[i] - 'a'])
        		{
        			cout << str[i];
        			return 0;
        		}
        	}
        	cout << "no";
        	return 0;
        }
        
        • 1
          @ 2024-1-6 11:45:11
          #include <iostream>
          using namespace std;
          bool x[30],y[30];
          int main(){
          	string a;cin>>a;
          	for(int i=0;i<a.size();i++){
          		if(x[a[i]-'a']){
          			y[a[i]-'a']=true;
          		}
          		x[a[i]-'a']=true;
          	}
          	for(int i=0;i<a.size();i++)
          		if(!y[a[i]-'a']){
          			cout << a[i];
          			return 0;
          		}
          	cout<<"no";
          	return 0;
          }
          
          • 1
            @ 2023-10-13 20:15:43
            using namespace std;
            int maxx = 0x7fffffff;//这个是无穷大的意思
            int main()
            {
            	string a;
            	int cc=0,minn=maxx;
            	char b;
            	int flag[30] = {};
            	int sx[30] = {};
            	getline(cin,a);
            	memset(sx,maxx,sizeof(sx));
            	for (int i=0;i<a.length();i++)
            	{
            		cc++;
            		if (!flag[int(a[i])-96])
            		{
            			sx[int(a[i])-96] = cc;
            		}
            		flag[int(a[i])-96]++;
            	} 
            	bool g = false;
            	for (int i=1;i<=26;i++)
            	{
            		if (flag[i]==1 && sx[i]<minn)
            		{
            			minn=sx[i];
            			b=char(96+i);
            			g=true;
            		}
            	}
            	if (g){
            		cout << b;
            	}else{
            		cout << "no";
            	}
             }
            
            • 1
              @ 2023-10-13 20:07:17
              #include<iostream>
              using namespace std;
              bool 进来的[30];
              bool 值[30];
              int main(){
              	string a;//设一个串
              	cin >> a;//输入
              	for(int i = 0; i < a.size(); i++){
              		if(进来的[a[i] - 'a']){//判断进来的东东
              			值[a[i] - 'a'] = true;//
              		}
              		进来的[a[i] - 'a'] = true;//
              	}
              	for(int i = 0; i < a.size(); i++){
              		if(!值[a[i] - 'a']){
              			cout << a[i];//
              			return 0;
              		}
              	}
              	cout << "no";//
              	return 0;
              }
              
              
              • 0
                @ 2025-2-4 20:38:14
                //结构体
                #include<iostream>
                #include<string>
                #include<algorithm>
                #include<cmath>
                using namespace std;
                char a;
                short j;
                struct num{
                   bool fl=false;
                   char cha;
                   int sum,inx=999;
                }nu[26],nu2[26];
                bool comp(num x,num y){
                   if(x.inx<y.inx) return 1;
                   return 0;
                }
                int main(){
                   while(cin>>a){
                      j++;
                      nu[abs(97-a)].sum++;
                      if(nu[abs(97-a)].sum==1) nu[abs(97-a)].inx=0;
                      nu[abs(97-a)].inx+=j;
                      nu[abs(97-a)].cha=a;
                   }
                   for(int i=0;i<=26;i++){
                      if(nu[i].sum==1){
                         nu[i].fl=true;}
                   }
                   j=0;
                   for(int i=0;i<=26;i++){
                      if(nu[i].fl==true){
                         nu2[j].cha=nu[i].cha;
                         nu2[j].inx=nu[i].inx;
                         j++;}
                   }
                   sort(nu2,nu2+26,comp);
                   if(!(nu2[0].cha>='a' and nu[0].cha<='z')){
                      cout<<"no";
                      return 0;}
                   cout<<nu2[0].cha;
                   return 0;}
                
                • 0
                  @ 2024-12-25 17:03:44
                  #include<iostream>
                  using namespace std;
                  bool b[100001];
                  int main () {
                  	string a;
                  	cin>>a;
                  	long long i=0;
                  	while(i<a.size()) {
                  		long long j=a.size()-1;
                  		while(j>i) {
                  			if(b[i]==1) {
                  				break;
                  			}
                  			if(a[j]==a[i]) {
                  				b[j]=1;
                  				b[i]=1;
                  			}
                  			j--;
                  		}
                  		i++;
                  	}
                  	i=0;
                  	while(i<a.size()) {
                  		if(b[i]==0) {
                  			cout<<a[i];
                  			return 0;
                  		}
                  		i++;
                  	}
                  	cout<<"no";
                  	return 0;
                  }
                  

                  #include<iostream>
                  #include<queue>
                  #include<stack>
                  #include<cmath>
                  #include<algorithm>
                  #include<cstring>
                  using namespace std;   
                  bool b[100001];
                  int main ()
                  {
                      string a;
                      cin>>a;
                      long long i=0;
                      while(i<a.size())
                      {
                          long long j=a.size()-1;
                          while(j>i)
                          {
                          	if(b[i]==1)
                          	{
                          		break;
                  			}
                              if(a[j]==a[i])
                              {
                                  b[j]=1;
                                  b[i]=1;
                              }
                              j--;
                          }
                          i++;
                      }
                      i=0;
                      while(i<a.size())
                      {
                          if(b[i]==0)
                          {
                              cout<<a[i];
                              return 0;
                          }
                          i++;
                      }
                      cout<<"no";
                      return 0;
                  }
                  

                  h-h

                  不要抄哦!

                  • 1

                  Information

                  ID
                  616
                  Time
                  1000ms
                  Memory
                  256MiB
                  Difficulty
                  7
                  Tags
                  # Submissions
                  197
                  Accepted
                  47
                  Uploaded By