Submission #18110609


Source Code Expand

#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = my_getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
int N;
char S[7];
char T[7];
int main(){
  int i;
  rd(N);
  rd(S);
  for(i=(0);i<(N);i++){
    T[i] = S[i];
  }
  sort(T, T+N);
  do{
    for(i=(0);i<(N);i++){
      if(T[i] != S[i]){
        break;
      }
    }
    if(i==N){
      continue;
    }
    for(i=(0);i<(N);i++){
      if(T[i] != S[N-1-i]){
        break;
      }
    }
    if(i==N){
      continue;
    }
    wt_L(T);
    wt_L('\n');
    return 0;
  }
  while(next_permutation(T,T+N));
  wt_L("None");
  wt_L('\n');
  return 0;
}
// cLay varsion 20201115-2

// --- original code ---
// int N;
// char S[7], T[7];
// {
//   rd(N,S);
//   rep(i,N) T[i] = S[i];
//   sort(T, T+N);
//   do{
//     rep(i,N) if(T[i] != S[i]) break;
//     if(i==N) continue;
//     rep(i,N) if(T[i] != S[N-1-i]) break;
//     if(i==N) continue;
//     wt(T), return 0;
//   }while(next_permutation(T,T+N));
//   wt("None");
// }

Submission Info

Submission Time
Task E - アナグラム
User LayCurse
Language C++ (GCC 9.2.1)
Score 7
Code Size 2794 Byte
Status AC
Exec Time 7 ms
Memory 3632 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 7 / 7
Status
AC × 2
AC × 42
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All 5_random_00.txt, 5_random_01.txt, 5_random_02.txt, 5_random_03.txt, 5_random_04.txt, 5_random_05.txt, 5_random_06.txt, 5_random_07.txt, 5_random_08.txt, 5_random_09.txt, 5_random_10.txt, 5_random_11.txt, 5_random_12.txt, 5_random_13.txt, 5_random_14.txt, full_00.txt, full_01.txt, full_02.txt, full_03.txt, full_04.txt, full_05.txt, full_06.txt, full_07.txt, full_08.txt, full_09.txt, full_10.txt, full_11.txt, full_12.txt, full_13.txt, full_14.txt, full_15.txt, full_16.txt, full_17.txt, full_18.txt, full_19.txt, full_20.txt, full_21.txt, full_22.txt, hand_01.txt, hand_02.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
5_random_00.txt AC 5 ms 3528 KiB
5_random_01.txt AC 2 ms 3404 KiB
5_random_02.txt AC 3 ms 3416 KiB
5_random_03.txt AC 2 ms 3576 KiB
5_random_04.txt AC 2 ms 3532 KiB
5_random_05.txt AC 2 ms 3460 KiB
5_random_06.txt AC 2 ms 3628 KiB
5_random_07.txt AC 2 ms 3632 KiB
5_random_08.txt AC 2 ms 3460 KiB
5_random_09.txt AC 3 ms 3600 KiB
5_random_10.txt AC 2 ms 3628 KiB
5_random_11.txt AC 3 ms 3552 KiB
5_random_12.txt AC 6 ms 3576 KiB
5_random_13.txt AC 3 ms 3456 KiB
5_random_14.txt AC 2 ms 3444 KiB
full_00.txt AC 2 ms 3528 KiB
full_01.txt AC 2 ms 3528 KiB
full_02.txt AC 2 ms 3560 KiB
full_03.txt AC 2 ms 3464 KiB
full_04.txt AC 2 ms 3632 KiB
full_05.txt AC 3 ms 3532 KiB
full_06.txt AC 2 ms 3604 KiB
full_07.txt AC 2 ms 3444 KiB
full_08.txt AC 2 ms 3532 KiB
full_09.txt AC 2 ms 3540 KiB
full_10.txt AC 2 ms 3452 KiB
full_11.txt AC 2 ms 3536 KiB
full_12.txt AC 3 ms 3456 KiB
full_13.txt AC 2 ms 3600 KiB
full_14.txt AC 3 ms 3572 KiB
full_15.txt AC 7 ms 3596 KiB
full_16.txt AC 2 ms 3412 KiB
full_17.txt AC 2 ms 3444 KiB
full_18.txt AC 3 ms 3560 KiB
full_19.txt AC 3 ms 3460 KiB
full_20.txt AC 2 ms 3452 KiB
full_21.txt AC 2 ms 3628 KiB
full_22.txt AC 2 ms 3600 KiB
hand_01.txt AC 2 ms 3600 KiB
hand_02.txt AC 2 ms 3576 KiB
sample_01.txt AC 2 ms 3556 KiB
sample_02.txt AC 2 ms 3464 KiB