Submission #2286159


Source Code Expand

Copy
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
map<char,bool> mp;
string a;
char c='.';
string b("abcdefghijklmnopqrstuvwxyz");
string mx("zyxwvutsrqponmlkjihgfedcba");
int main()
{
    cin>>a;
    for (int i=0;i<a.size();i++)
        mp[a[i]]=true;
    for (int i=0;i<26;i++)
        if (!mp[b[i]]) {c=b[i];break;}
    if (c=='.' && a==mx) {cout<<"-1"<<endl;system("pause");return 0;}
    else if (c!='.') {cout<<a<<c<<endl;system("pause");return 0;}
    int flag=0;
    for (int i=25;i>0;i--)
    {
        flag=i;
        if (a[i-1]<a[i]) {for (int j=0;j<26;j++) if (a[i-1]==b[j]) {c=b[j+1];break;} break;}
    }
    for (int i=0;i<flag-1;i++)
        cout<<a[i];
    cout<<c<<endl;
    return 0;
}

Submission Info

Submission Time
Task A - Diverse Word
User momo2007
Language C++14 (GCC 5.4.1)
Score 0
Code Size 881 Byte
Status
Exec Time 2 ms
Memory 504 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:24:59: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
     if (c=='.' && a==mx) {cout<<"-1"<<endl;system("pause");return 0;}
                                                           ^
./Main.cpp:25:55: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
     else if (c!='.') {cout<<a<<c<<endl;system("pause");return 0;}
                                                       ^

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt, s3.txt, s4.txt
All 0 / 300 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, s1.txt, s2.txt, s3.txt, s4.txt
Case Name Status Exec Time Memory
01.txt 1 ms 256 KB
02.txt 1 ms 256 KB
03.txt 1 ms 256 KB
04.txt 2 ms 504 KB
05.txt 2 ms 504 KB
06.txt 2 ms 504 KB
07.txt 2 ms 504 KB
08.txt 2 ms 504 KB
09.txt 2 ms 504 KB
10.txt 1 ms 256 KB
11.txt 1 ms 256 KB
12.txt 1 ms 256 KB
13.txt 1 ms 256 KB
14.txt 1 ms 256 KB
15.txt 1 ms 256 KB
16.txt 1 ms 256 KB
17.txt 1 ms 256 KB
18.txt 1 ms 256 KB
19.txt 1 ms 256 KB
s1.txt 2 ms 504 KB
s2.txt 2 ms 504 KB
s3.txt 2 ms 504 KB
s4.txt 1 ms 256 KB