7 solutions

  • 0
    @ 2024-3-2 15:46:42
    #include<bits/stdc++.h>
    using namespace std;
    const int N=10010;
    bool  f[N][N];
    //f[i][j]=1 表示i到j这段是回文串 
    int main()
    {
    	string s;
    	cin>>s;
    	int n=s.size();
    	s=" "+s;
    	for(int i=1;i<=n;i++) f[i][i]=1; //一个字符一定是回文 
    	int ans=n;
    	for(int i=n;i>=1;i--)
    	{
    		for(int j=i+1;j<=n;j++)
    		{
    			if(s[i]!=s[j]) continue;//一定不符合要求 
    			if(j==i+1||f[i+1][j-1])
    			{
    				ans++;
    				f[i][j]=true;
    			}
    		}
    	}
    	cout<<ans;
    	return 0;
    }
    
    • -1
      @ 2025-3-1 10:47:37
      #include<bits/stdc++.h>
      using namespace std;
      const int N=10010;
      bool  f[N][N];
      //f[i][j]=1 表示i到j这段是回文串 
      int main()
      {
      	string s;
      	cin>>s;
      	int n=s.size();
      	s=" "+s;
      	for(int i=1;i<=n;i++) f[i][i]=1; //一个字符一定是回文 
      	int ans=n;
      	for(int i=n;i>=1;i--)
      	{
      		for(int j=i+1;j<=n;j++)
      		{
      			if(s[i]!=s[j]) continue;//一定不符合要求 
      			if(j==i+1||f[i+1][j-1])
      			{
      				ans++;
      				f[i][j]=true;
      			}
      		}
      	}
      	cout<<ans;
      	return 0;
      }
      • -1
        @ 2025-3-1 10:46:45
        #include<bits/stdc++.h>
        using namespace std;
        const int N=10010;
        bool  f[N][N];
        //f[i][j]=1 表示i到j这段是回文串 
        int main()
        {
        	string s;
        	cin>>s;
        	int n=s.size();
        	s=" "+s;
        	for(int i=1;i<=n;i++) f[i][i]=1; //一个字符一定是回文 
        	int ans=n;
        	for(int i=n;i>=1;i--)
        	{
        		for(int j=i+1;j<=n;j++)
        		{
        			if(s[i]!=s[j]) continue;//一定不符合要求 
        			if(j==i+1||f[i+1][j-1])
        			{
        				ans++;
        				f[i][j]=true;
        			}
        		}
        	}
        	cout<<ans;
        	return 0;
        }
        • -1
          @ 2025-3-1 10:46:23
          #include<bits/stdc++.h>
          using namespace std;
          const int N=10010;
          bool  f[N][N];
          //f[i][j]=1 表示i到j这段是回文串 
          int main()
          {
          	string s;
          	cin>>s;
          	int n=s.size();
          	s=" "+s;
          	for(int i=1;i<=n;i++) f[i][i]=1; //一个字符一定是回文 
          	int ans=n;
          	for(int i=n;i>=1;i--)
          	{
          		for(int j=i+1;j<=n;j++)
          		{
          			if(s[i]!=s[j]) continue;//一定不符合要求 
          			if(j==i+1||f[i+1][j-1])
          			{
          				ans++;
          				f[i][j]=true;
          			}
          		}
          	}
          	cout<<ans;
          	return 0;
          }
          • -1
            @ 2025-3-1 10:44:34
            #include<bits/stdc++.h>
            using namespace std;
            const int N=10010;
            bool  f[N][N];
            //f[i][j]=1 表示i到j这段是回文串 
            int main()
            {
            	string s;
            	cin>>s;
            	int n=s.size();
            	s=" "+s;
            	for(int i=1;i<=n;i++) f[i][i]=1; //一个字符一定是回文 
            	int ans=n;
            	for(int i=n;i>=1;i--)
            	{
            		for(int j=i+1;j<=n;j++)
            		{
            			if(s[i]!=s[j]) continue;//一定不符合要求 
            			if(j==i+1||f[i+1][j-1])
            			{
            				ans++;
            				f[i][j]=true;
            			}
            		}
            	}
            	cout<<ans;
            	return 0;
            }
            • -1
              @ 2025-3-1 10:43:33
              #include<bits/stdc++.h>
              using namespace std;
              const int N=10010;
              bool  f[N][N];
              //f[i][j]=1 表示i到j这段是回文串 
              int main()
              {
              	string s;
              	cin>>s;
              	int n=s.size();
              	s=" "+s;
              	for(int i=1;i<=n;i++) f[i][i]=1; //一个字符一定是回文 
              	int ans=n;
              	for(int i=n;i>=1;i--)
              	{
              		for(int j=i+1;j<=n;j++)
              		{
              			if(s[i]!=s[j]) continue;//一定不符合要求 
              			if(j==i+1||f[i+1][j-1])
              			{
              				ans++;
              				f[i][j]=true;
              			}
              		}
              	}
              	cout<<ans;
              	return 0;
              }
              • -2
                @ 2024-3-2 15:51:24
                #include<bits/stdc++.h>
                using namespace std;
                const int N=1010;
                int f[N][N];
                //f[i][j]=1 表示i到j这段是回文串 
                int main()
                {
                	string s;
                	cin>>s;
                	int n=s.size();
                	s=" "+s;
                	for(int i=1;i<=n;i++) f[i][i]=1; //一个字符一定是回文 
                	int ans=n;
                	for(int i=n;i>=1;i--)
                	{
                		for(int j=i+1;j<=n;j++)
                		{
                			if(s[i]!=s[j]) continue;//一定不符合要求 
                			if(j==i+1||f[i+1][j-1])
                			{
                				ans++;
                				f[i][j]=true;
                			}
                		}
                	}
                	cout<<ans;
                	return 0;
                }
                
                • 1

                Information

                ID
                208
                Time
                1000ms
                Memory
                256MiB
                Difficulty
                7
                Tags
                # Submissions
                44
                Accepted
                10
                Uploaded By