Submission #1213039


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

typedef bitset<10001> bit;
int n;
char s[12525][25];
char t[25];

int check(char s[25], char t[25]){
  int n = strlen(s);
  int ret = 0;  // 1 : le, 2 : ge
  char x[25];
  x[n] = '\0';
  // minimize
  REP(i,n)x[i] = s[i]=='?' ? 'a' : s[i];
  if(strcmp(x,t)<=0)ret |= 1;
  // maximize
  REP(i,n)x[i] = s[i]=='?' ? 'z' : s[i];
  if(strcmp(x,t)>=0)ret |= 2;
  return ret;
}

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%s",s[i]);
  scanf("%s",t);
  bit ans;
  ans.set(0);
  REP(i,n){
    int o = check(s[i], t);
    bit nxt;
    if(o & 1)nxt |= ans<<1;
    if(o & 2)nxt |= ans;
    ans = nxt;
  }
  vi v;
  REP(i,n+1)if(ans[i])v.push_back(i+1);
  REP(i,v.size()){
    printf("%d%c",v[i],i==v.size()-1?'\n':' ');
  }
  return 0;
}

Submission Info

Submission Time
Task A - Atcoder Handles
User rickytheta
Language C++14 (GCC 5.4.1)
Score 250
Code Size 1638 Byte
Status AC
Exec Time 6 ms
Memory 512 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:54:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&n);
                 ^
./Main.cpp:55:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   REP(i,n)scanf("%s",s[i]);
                           ^
./Main.cpp:56:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s",t);
                ^

Judge Result

Set Name Subtask1 Subtask2
Score / Max Score 130 / 130 120 / 120
Status
AC × 3
AC × 6
Set Name Test Cases
Subtask1 sub1_in1.txt, sub1_in2.txt, sub1_in3.txt
Subtask2 sub1_in1.txt, sub1_in2.txt, sub1_in3.txt, sub2_in1.txt, sub2_in2.txt, sub2_in3.txt
Case Name Status Exec Time Memory
sub1_in1.txt AC 1 ms 256 KB
sub1_in2.txt AC 1 ms 256 KB
sub1_in3.txt AC 1 ms 256 KB
sub2_in1.txt AC 1 ms 256 KB
sub2_in2.txt AC 4 ms 384 KB
sub2_in3.txt AC 6 ms 512 KB