QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#427592#8776. Not Another Constructive!ucup-team112#AC ✓72ms221356kbC++2011.5kb2024-06-01 14:03:382024-06-01 14:03:39

Judging History

你现在查看的是最新测评结果

  • [2024-06-01 14:03:39]
  • 评测
  • 测评结果:AC
  • 用时:72ms
  • 内存:221356kb
  • [2024-06-01 14:03:38]
  • 提交

answer


//#define _GLIBCXX_DEBUG

//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
using namespace std;


#ifdef LOCAL
#include <debug_print.hpp>
#define OUT(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#define OUT(...) (static_cast<void>(0))
#endif

#define endl '\n'
#define lfs cout<<fixed<<setprecision(15)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)

namespace template_tute{
  using ll = long long;
  using ld = long double;
  const ll MOD1 = 1e9+7;
  const ll MOD9 = 998244353;
  const ll INF = 1e18;
  using P = pair<ll, ll>;
  template<typename T> using PQ = priority_queue<T>;
  template<typename T> using QP = priority_queue<T,vector<T>,greater<T>>;
  template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
  template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
  ll median(ll a,ll b, ll c){return a+b+c-max<ll>({a,b,c})-min<ll>({a,b,c});}
  void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
  void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
  void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
  template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
  template<typename T1,typename T2,typename T3>void anss(T1 x,T2 y,T3 z){ans(x!=y,x,z);};  
  template<typename T>void debug(const T &v,ll h,ll w,string sv=" "){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout<<sv<<v[i][j];cout<<endl;}};
  template<typename T>void debug(const T &v,ll n,string sv=" "){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout<<sv<<v[i];cout<<endl;};
  template<typename T>void debug(const vector<T>&v){debug(v,v.size());}
  template<typename T>void debug(const vector<vector<T>>&v){for(auto &vv:v)debug(vv,vv.size());}
  template<typename T>void debug(stack<T> st){while(!st.empty()){cout<<st.top()<<" ";st.pop();}cout<<endl;}
  template<typename T>void debug(queue<T> st){while(!st.empty()){cout<<st.front()<<" ";st.pop();}cout<<endl;}
  template<typename T>void debug(deque<T> st){while(!st.empty()){cout<<st.front()<<" ";st.pop_front();}cout<<endl;}
  template<typename T>void debug(PQ<T> st){while(!st.empty()){cout<<st.top()<<" ";st.pop();}cout<<endl;}
  template<typename T>void debug(QP<T> st){while(!st.empty()){cout<<st.top()<<" ";st.pop();}cout<<endl;}
  template<typename T>void debug(const set<T>&v){for(auto z:v)cout<<z<<" ";cout<<endl;}
  template<typename T>void debug(const multiset<T>&v){for(auto z:v)cout<<z<<" ";cout<<endl;}
  template<typename T,size_t size>void debug(const array<T, size> &a){for(auto z:a)cout<<z<<" ";cout<<endl;}
  template<typename T,typename V>void debug(const map<T,V>&v){for(auto z:v)cout<<"["<<z.first<<"]="<<z.second<<",";cout<<endl;}
  template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
  vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
  template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
  template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
  template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << "(" << p.first << "," << p.second << ")";}
  template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){os<<"[";for(auto &z:v)os << z << ",";os<<"]"; return os;}
  template<typename T>void rearrange(vector<int>&ord, vector<T>&v){
    auto tmp = v;
    for(int i=0;i<tmp.size();i++)v[i] = tmp[ord[i]];
  }
  template<typename Head, typename... Tail>void rearrange(vector<int>&ord,Head&& head, Tail&&... tail){
    rearrange(ord, head);
    rearrange(ord, tail...);
  }
  template<typename T> vector<int> ascend(const vector<T>&v){
    vector<int>ord(v.size());iota(ord.begin(),ord.end(),0);
    sort(ord.begin(),ord.end(),[&](int i,int j){return make_pair(v[i],i)<make_pair(v[j],j);});
    return ord;
  }
  template<typename T> vector<int> descend(const vector<T>&v){
    vector<int>ord(v.size());iota(ord.begin(),ord.end(),0);
    sort(ord.begin(),ord.end(),[&](int i,int j){return make_pair(v[i],-i)>make_pair(v[j],-j);});
    return ord;
  }
  template<typename T> vector<T> inv_perm(const vector<T>&ord){
    vector<T>inv(ord.size());
    for(int i=0;i<ord.size();i++)inv[ord[i]] = i;
    return inv;
  }
  ll FLOOR(ll n,ll div){assert(div>0);return n>=0?n/div:(n-div+1)/div;}
  ll CEIL(ll n,ll div){assert(div>0);return n>=0?(n+div-1)/div:n/div;}
  ll digitsum(ll n){ll ret=0;while(n){ret+=n%10;n/=10;}return ret;}
  ll modulo(ll n,ll d){return (n%d+d)%d;};
  template<typename T>T min(const vector<T>&v){return *min_element(v.begin(),v.end());}
  template<typename T>T max(const vector<T>&v){return *max_element(v.begin(),v.end());}
  template<typename T>T acc(const vector<T>&v){return accumulate(v.begin(),v.end(),T(0));};
  template<typename T>T reverse(const T &v){return T(v.rbegin(),v.rend());};
  //mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
  int popcount(ll x){return __builtin_popcountll(x);};
  int poplow(ll x){return __builtin_ctzll(x);};
  int pophigh(ll x){return 63 - __builtin_clzll(x);};
  template<typename T>T poll(queue<T> &q){auto ret=q.front();q.pop();return ret;};
  template<typename T>T poll(priority_queue<T> &q){auto ret=q.top();q.pop();return ret;};
  template<typename T>T poll(QP<T> &q){auto ret=q.top();q.pop();return ret;};
  template<typename T>T poll(stack<T> &s){auto ret=s.top();s.pop();return ret;};
  ll MULT(ll x,ll y){if(LLONG_MAX/x<=y)return LLONG_MAX;return x*y;}
  ll POW2(ll x, ll k){ll ret=1,mul=x;while(k){if(mul==LLONG_MAX)return LLONG_MAX;if(k&1)ret=MULT(ret,mul);mul=MULT(mul,mul);k>>=1;}return ret;}
  ll POW(ll x, ll k){ll ret=1;for(int i=0;i<k;i++){if(LLONG_MAX/x<=ret)return LLONG_MAX;ret*=x;}return ret;}
  std::ostream &operator<<(std::ostream &dest, __int128_t value) {
    std::ostream::sentry s(dest);
    if (s) {
      __uint128_t tmp = value < 0 ? -value : value;
      char buffer[128];
      char *d = std::end(buffer);
      do {
        --d;
        *d = "0123456789"[tmp % 10];
        tmp /= 10;
      } while (tmp != 0);
      if (value < 0) {
        --d;
        *d = '-';
      }
      int len = std::end(buffer) - d;
      if (dest.rdbuf()->sputn(d, len) != len) {
        dest.setstate(std::ios_base::badbit);
      }
    }
    return dest;
  }
  namespace converter{
    int dict[500];
    const string lower="abcdefghijklmnopqrstuvwxyz";
    const string upper="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    const string digit="0123456789";
    const string digit1="123456789";
    void regi_str(const string &t){
      for(int i=0;i<t.size();i++){
        dict[t[i]]=i;
      }
    }
    void regi_int(const string &t){
      for(int i=0;i<t.size();i++){
        dict[i]=t[i];
      }
    }
    vector<int>to_int(const string &s,const string &t){
      regi_str(t);
      vector<int>ret(s.size());
      for(int i=0;i<s.size();i++){
        ret[i]=dict[s[i]];
      }
      return ret;
    }
    vector<int>to_int(const string &s){
      auto t=s;
      sort(t.begin(),t.end());
      t.erase(unique(t.begin(),t.end()),t.end());
      return to_int(s,t);
    }
    
    vector<vector<int>>to_int(const vector<string>&s,const string &t){
      regi_str(t);
      vector<vector<int>>ret(s.size(),vector<int>(s[0].size()));
      for(int i=0;i<s.size();i++){
        for(int j=0;j<s[0].size();j++){
          ret[i][j]=dict[s[i][j]];
        }
      }
      return ret;
    }
    vector<vector<int>>to_int(const vector<string>&s){
      string t;
      for(int i=0;i<s.size();i++){
        t+=s[i];
      }
      sort(t.begin(),t.end());t.erase(unique(t.begin(),t.end()),t.end());
      return to_int(s,t);
    }
    string to_str(const vector<int>&s,const string &t){
      regi_int(t);
      string ret;
      for(auto z:s)ret+=dict[z];
      return ret;
    }
    vector<string> to_str(const vector<vector<int>>&s,const string &t){
      regi_int(t);
      vector<string>ret(s.size());
      for(int i=0;i<s.size();i++){
        for(auto z:s[i])ret[i]+=dict[z];
      }
      return ret;
    }
  }
  template< typename T = int >
  struct edge {
    int to;
    T cost;
    int id;
    edge():to(-1),id(-1){};
    edge(int to, T cost = 1, int id = -1):to(to), cost(cost), id(id){}
    operator int() const { return to; }
  };

  template<typename T>
  using Graph = vector<vector<edge<T>>>;
  template<typename T>
  Graph<T>revgraph(const Graph<T> &g){
    Graph<T>ret(g.size());
    for(int i=0;i<g.size();i++){
      for(auto e:g[i]){
        int to = e.to;
        e.to = i;
        ret[to].push_back(e);
      }
    }
    return ret;
  }
  template<typename T>
  Graph<T> readGraph(int n,int m,int indexed=1,bool directed=false,bool weighted=false){
    Graph<T> ret(n);
    for(int es = 0; es < m; es++){
      int u,v;
      T w=1;
      cin>>u>>v;u-=indexed,v-=indexed;
      if(weighted)cin>>w;
      ret[u].emplace_back(v,w,es);
      if(!directed)ret[v].emplace_back(u,w,es);
    }
    return ret;
  }
  template<typename T>
  Graph<T> readParent(int n,int indexed=1,bool directed=true){
    Graph<T>ret(n);
    for(int i=1;i<n;i++){
      int p;cin>>p;
      p-=indexed;
      ret[p].emplace_back(i);
      if(!directed)ret[i].emplace_back(p);
    }
    return ret;
  }
}
using namespace template_tute;

void solve(){
	ll res=0,buf=0;
  bool judge = true;

  int n,k;cin>>n>>k;
  string s;cin>>s;
  const int sz1=405;
  //const int sz1=3;
  const int sz2=2505;
  //const int sz2=6;
  auto dp=make_v(n+1,n+1,sz1,bitset<sz2>(0));
  dp[0][0][0]=1;
  vector<int>bc(n);
  rep(i,0,n){
    int can=15;
    if(s[i]=='N')can=1;
    else if(s[i]=='A')can=2;
    else if(s[i]=='C')can=4;
    else if(s[i]!='?')can=8;
    bc[i]=can;
    rep(j,0,i+1){
      rep(o,0,sz1){
        rep(b,0,4){
          if(~can>>b&1)continue;
          int sn=0,sna=0,snac=0;
          if(b==0)sn++;
          if(b==1)sna+=j;
          if(b==2)snac+=o;
          if(j+sn>n||o+sna>=sz1)continue;
          dp[i+1][j+sn][o+sna]|=dp[i][j][o]<<snac;
        }
      }
    }
  }
  //OUT(dp);
  rep(ej,0,n+1){
    rep(eo,0,sz1){
      if(dp[n][ej][eo][k]){
        string ret=s;
        rrep(i,0,n){
          int can=bc[i];
          rep(b,0,4){
            if(~can>>b&1)continue;
            int sn=0,sna=0,snac=0;
            if(b==0)sn++;
            if(b==1)sna+=ej;
            if(b==2)snac+=eo;
            if(ej>=sn&&eo>=sna&&k>=snac&&dp[i][ej-sn][eo-sna][k-snac]){
              if(b==0)ret[i]='N';
              if(b==1)ret[i]='A';
              if(b==2)ret[i]='C';
              if(b==3)ret[i]=(s[i]=='?'?'X':s[i]);
              ej-=sn;
              eo-=sna;
              k-=snac;
              break;
            }
          }
        }
        cout<<ret<<endl;
        return;
      }
    }
  }
  cout<<-1<<endl;
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  int T = 1;
  //cin>>T;
  while(T--){
    solve();
  }
  return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 29ms
memory: 73188kb

input:

22 2
N??A??????C???????????

output:

NCCAXXXXXXCXXXXXXXXXXC

result:

ok correct

Test #2:

score: 0
Accepted
time: 7ms
memory: 51456kb

input:

18 0
COUNTINGSATELLITES

output:

COUNTINGSATELLITES

result:

ok correct

Test #3:

score: 0
Accepted
time: 1ms
memory: 4724kb

input:

2 1
??

output:

-1

result:

ok correct

Test #4:

score: 0
Accepted
time: 1ms
memory: 4352kb

input:

1 0
?

output:

A

result:

ok correct

Test #5:

score: 0
Accepted
time: 1ms
memory: 4112kb

input:

1 0
N

output:

N

result:

ok correct

Test #6:

score: 0
Accepted
time: 0ms
memory: 4344kb

input:

1 0
X

output:

X

result:

ok correct

Test #7:

score: 0
Accepted
time: 0ms
memory: 4204kb

input:

1 1
?

output:

-1

result:

ok correct

Test #8:

score: 0
Accepted
time: 1ms
memory: 4272kb

input:

1 1
N

output:

-1

result:

ok correct

Test #9:

score: 0
Accepted
time: 1ms
memory: 4208kb

input:

1 1
X

output:

-1

result:

ok correct

Test #10:

score: 0
Accepted
time: 0ms
memory: 4808kb

input:

2 0
??

output:

AA

result:

ok correct

Test #11:

score: 0
Accepted
time: 1ms
memory: 4652kb

input:

2 0
N?

output:

NC

result:

ok correct

Test #12:

score: 0
Accepted
time: 1ms
memory: 4648kb

input:

2 0
?C

output:

AC

result:

ok correct

Test #13:

score: 0
Accepted
time: 1ms
memory: 4688kb

input:

2 1
N?

output:

-1

result:

ok correct

Test #14:

score: 0
Accepted
time: 1ms
memory: 4852kb

input:

2 1
?C

output:

-1

result:

ok correct

Test #15:

score: 0
Accepted
time: 0ms
memory: 5912kb

input:

3 1
???

output:

NAC

result:

ok correct

Test #16:

score: 0
Accepted
time: 0ms
memory: 5716kb

input:

3 1
N??

output:

NAC

result:

ok correct

Test #17:

score: 0
Accepted
time: 0ms
memory: 5764kb

input:

3 1
?A?

output:

NAC

result:

ok correct

Test #18:

score: 0
Accepted
time: 0ms
memory: 5788kb

input:

3 1
??C

output:

NAC

result:

ok correct

Test #19:

score: 0
Accepted
time: 2ms
memory: 5704kb

input:

3 1
NA?

output:

NAC

result:

ok correct

Test #20:

score: 0
Accepted
time: 0ms
memory: 5776kb

input:

3 1
N?C

output:

NAC

result:

ok correct

Test #21:

score: 0
Accepted
time: 2ms
memory: 5804kb

input:

3 1
?AC

output:

NAC

result:

ok correct

Test #22:

score: 0
Accepted
time: 0ms
memory: 7124kb

input:

4 1
????

output:

ANAC

result:

ok correct

Test #23:

score: 0
Accepted
time: 3ms
memory: 7000kb

input:

4 1
X???

output:

XNAC

result:

ok correct

Test #24:

score: 0
Accepted
time: 0ms
memory: 7092kb

input:

4 1
???Z

output:

NACZ

result:

ok correct

Test #25:

score: 0
Accepted
time: 3ms
memory: 7120kb

input:

4 1
?AA?

output:

-1

result:

ok correct

Test #26:

score: 0
Accepted
time: 3ms
memory: 7108kb

input:

4 1
N???

output:

NCAC

result:

ok correct

Test #27:

score: 0
Accepted
time: 0ms
memory: 7040kb

input:

4 1
?N??

output:

ANAC

result:

ok correct

Test #28:

score: 0
Accepted
time: 3ms
memory: 7192kb

input:

4 1
??N?

output:

NANC

result:

ok correct

Test #29:

score: 0
Accepted
time: 0ms
memory: 7048kb

input:

4 1
???N

output:

NACN

result:

ok correct

Test #30:

score: 0
Accepted
time: 2ms
memory: 7116kb

input:

4 1
A???

output:

ANAC

result:

ok correct

Test #31:

score: 0
Accepted
time: 0ms
memory: 7256kb

input:

4 1
?A??

output:

NAXC

result:

ok correct

Test #32:

score: 0
Accepted
time: 2ms
memory: 7036kb

input:

4 1
??A?

output:

ANAC

result:

ok correct

Test #33:

score: 0
Accepted
time: 2ms
memory: 7080kb

input:

4 1
???A

output:

NACA

result:

ok correct

Test #34:

score: 0
Accepted
time: 3ms
memory: 7024kb

input:

4 1
C???

output:

CNAC

result:

ok correct

Test #35:

score: 0
Accepted
time: 0ms
memory: 7120kb

input:

4 1
?C??

output:

NCAC

result:

ok correct

Test #36:

score: 0
Accepted
time: 0ms
memory: 7084kb

input:

4 1
??C?

output:

NACX

result:

ok correct

Test #37:

score: 0
Accepted
time: 0ms
memory: 7228kb

input:

4 1
???C

output:

ANAC

result:

ok correct

Test #38:

score: 0
Accepted
time: 4ms
memory: 8616kb

input:

5 4
?????

output:

NAACC

result:

ok correct

Test #39:

score: 0
Accepted
time: 0ms
memory: 10464kb

input:

6 14
??????

output:

-1

result:

ok correct

Test #40:

score: 0
Accepted
time: 0ms
memory: 12456kb

input:

7 14
???????

output:

-1

result:

ok correct

Test #41:

score: 0
Accepted
time: 0ms
memory: 14676kb

input:

8 43
????????

output:

-1

result:

ok correct

Test #42:

score: 0
Accepted
time: 4ms
memory: 17052kb

input:

9 55
?????????

output:

-1

result:

ok correct

Test #43:

score: 0
Accepted
time: 7ms
memory: 19984kb

input:

10 112
??????????

output:

-1

result:

ok correct

Test #44:

score: 0
Accepted
time: 8ms
memory: 22936kb

input:

11 110
???????????

output:

-1

result:

ok correct

Test #45:

score: 0
Accepted
time: 6ms
memory: 26292kb

input:

12 4
????????????

output:

AAAAAANACCCC

result:

ok correct

Test #46:

score: 0
Accepted
time: 4ms
memory: 29812kb

input:

13 193
?????????????

output:

-1

result:

ok correct

Test #47:

score: 0
Accepted
time: 8ms
memory: 33896kb

input:

14 91
??????????????

output:

NNNANAAACACCCC

result:

ok correct

Test #48:

score: 0
Accepted
time: 7ms
memory: 37676kb

input:

15 15
???????????????

output:

NACCCCCCCCCACCC

result:

ok correct

Test #49:

score: 0
Accepted
time: 7ms
memory: 41840kb

input:

16 261
????????????????

output:

-1

result:

ok correct

Test #50:

score: 0
Accepted
time: 16ms
memory: 46720kb

input:

17 514
?????????????????

output:

-1

result:

ok correct

Test #51:

score: 0
Accepted
time: 12ms
memory: 51436kb

input:

18 678
??????????????????

output:

-1

result:

ok correct

Test #52:

score: 0
Accepted
time: 14ms
memory: 56468kb

input:

19 40
???????????????????

output:

NAACCCCCACCCCCCCCCC

result:

ok correct

Test #53:

score: 0
Accepted
time: 15ms
memory: 61876kb

input:

20 1019
????????????????????

output:

-1

result:

ok correct

Test #54:

score: 0
Accepted
time: 23ms
memory: 67384kb

input:

21 1218
?????????????????????

output:

-1

result:

ok correct

Test #55:

score: 0
Accepted
time: 15ms
memory: 73028kb

input:

22 1348
??????????????????????

output:

-1

result:

ok correct

Test #56:

score: 0
Accepted
time: 33ms
memory: 79180kb

input:

23 476
???????????????????????

output:

-1

result:

ok correct

Test #57:

score: 0
Accepted
time: 27ms
memory: 85508kb

input:

24 1445
????????????????????????

output:

-1

result:

ok correct

Test #58:

score: 0
Accepted
time: 37ms
memory: 92032kb

input:

25 1331
?????????????????????????

output:

-1

result:

ok correct

Test #59:

score: 0
Accepted
time: 41ms
memory: 98972kb

input:

26 459
??????????????????????????

output:

NNNANAAAAAAAAAAAACCCCCCCCC

result:

ok correct

Test #60:

score: 0
Accepted
time: 34ms
memory: 106024kb

input:

27 398
???????????????????????????

output:

NNANAAAAAAAAACCCCCCACCCCCCC

result:

ok correct

Test #61:

score: 0
Accepted
time: 40ms
memory: 113572kb

input:

28 274
????????????????????????????

output:

NNAAAAAAACCCCCCCACCCCCCCCCCC

result:

ok correct

Test #62:

score: 0
Accepted
time: 27ms
memory: 121224kb

input:

29 1624
?????????????????????????????

output:

-1

result:

ok correct

Test #63:

score: 0
Accepted
time: 45ms
memory: 128728kb

input:

30 2079
??????????????????????????????

output:

-1

result:

ok correct

Test #64:

score: 0
Accepted
time: 36ms
memory: 136888kb

input:

31 2067
???????????????????????????????

output:

-1

result:

ok correct

Test #65:

score: 0
Accepted
time: 32ms
memory: 145456kb

input:

32 1267
????????????????????????????????

output:

-1

result:

ok correct

Test #66:

score: 0
Accepted
time: 43ms
memory: 153812kb

input:

33 928
?????????????????????????????????

output:

NNNNAANAAAAAAAAAACCCCCCCCCCCCCCCC

result:

ok correct

Test #67:

score: 0
Accepted
time: 43ms
memory: 162784kb

input:

34 298
??????????????????????????????????

output:

NNAAAAACCCCCCCACCCCCCCCCCCCCCCCCCC

result:

ok correct

Test #68:

score: 0
Accepted
time: 56ms
memory: 171824kb

input:

35 2361
???????????????????????????????????

output:

-1

result:

ok correct

Test #69:

score: 0
Accepted
time: 53ms
memory: 181328kb

input:

36 489
????????????????????????????????????

output:

NANAAAAAAAAAAACCCCCCCCCCCCCCCCCCACCC

result:

ok correct

Test #70:

score: 0
Accepted
time: 56ms
memory: 190792kb

input:

37 294
?????????????????????????????????????

output:

NAAAAAAAAAAAACCCCCACCCCCCCCCCCCCCCCCC

result:

ok correct

Test #71:

score: 0
Accepted
time: 59ms
memory: 200956kb

input:

38 1558
??????????????????????????????????????

output:

NNNNNNAANAAAAAAAAAACCCCCCCCCCCCCCCCCCC

result:

ok correct

Test #72:

score: 0
Accepted
time: 71ms
memory: 210928kb

input:

39 1319
???????????????????????????????????????

output:

NNNNANAAAAAAAAAAACCCCCACCCCCCCCCCCCCCCC

result:

ok correct

Test #73:

score: 0
Accepted
time: 67ms
memory: 221280kb

input:

40 993
????????????????????????????????????????

output:

NNNAAAAAAAAAAAAAAACCCCCACCCCCCCCCCCCCCCC

result:

ok correct

Test #74:

score: 0
Accepted
time: 32ms
memory: 221128kb

input:

40 498
ACNANACNNACNACNNNCNCNNNANNNACNCCACAA?ANA

output:

-1

result:

ok correct

Test #75:

score: 0
Accepted
time: 47ms
memory: 221124kb

input:

40 855
NAAANAACNNNCNAANCNANCNANACANCCAANCACNCAC

output:

-1

result:

ok correct

Test #76:

score: 0
Accepted
time: 32ms
memory: 221136kb

input:

40 1007
?CNACNNAANACANACNACCC?CAANNCCCCANNANCACN

output:

-1

result:

ok correct

Test #77:

score: 0
Accepted
time: 47ms
memory: 221140kb

input:

40 1778
NACANANN?CCANNCCAACNNCCNCCCNCCNACCNC?NNN

output:

-1

result:

ok correct

Test #78:

score: 0
Accepted
time: 28ms
memory: 221188kb

input:

40 2186
ACCCACAN?NNA?AACCNNNN?ANACCANCNCNNCA?NCN

output:

-1

result:

ok correct

Test #79:

score: 0
Accepted
time: 69ms
memory: 221216kb

input:

40 332
ACAC?NCCCANAA?ACCNNC?NAC?CAC?CNCNNACNNNN

output:

-1

result:

ok correct

Test #80:

score: 0
Accepted
time: 44ms
memory: 221172kb

input:

40 712
ANCNANAAC?CACAACA?CNACCCANAACCA?CNNAANCN

output:

-1

result:

ok correct

Test #81:

score: 0
Accepted
time: 27ms
memory: 221172kb

input:

40 1127
C?CAAAANNCANANAC?NCANACANAACAACANNCCNCAC

output:

-1

result:

ok correct

Test #82:

score: 0
Accepted
time: 35ms
memory: 221204kb

input:

40 1835
CANNCAANNNAANANNCACANAC?CCCCAACA?NNNCAC?

output:

-1

result:

ok correct

Test #83:

score: 0
Accepted
time: 40ms
memory: 221128kb

input:

40 2009
CANAAAN?ANAACNCCNCCNCAAANCANCCAN?CCNCAAN

output:

-1

result:

ok correct

Test #84:

score: 0
Accepted
time: 36ms
memory: 221140kb

input:

40 54
CNAC?ACAAC?ACC?ANC?C?NNCAANCCAC?NCN?CACA

output:

-1

result:

ok correct

Test #85:

score: 0
Accepted
time: 47ms
memory: 221208kb

input:

40 955
?A?ANA?NN?C?ANC??CNNACAAC?N?AAN?AN??ANNA

output:

-1

result:

ok correct

Test #86:

score: 0
Accepted
time: 44ms
memory: 221124kb

input:

40 1451
??CCCA?N?ACCN?C???NNN??C?ANAN??NCNA??NAN

output:

-1

result:

ok correct

Test #87:

score: 0
Accepted
time: 51ms
memory: 221132kb

input:

40 1526
CN??AC?CCCCNACCNCNCCNC?CAAN?C?CA??ANCN?A

output:

-1

result:

ok correct

Test #88:

score: 0
Accepted
time: 50ms
memory: 221132kb

input:

40 2453
C?NC?CCAAN?ACCCNCC??ACAANCANCNCNNAACC?NN

output:

-1

result:

ok correct

Test #89:

score: 0
Accepted
time: 43ms
memory: 221224kb

input:

40 166
?NC??AACAN??NCA?CCAA?A??CNNN?ACNN?AN?ANC

output:

ANCCCAACANXCNCACCCAAXACCCNNNCACNNCANXANC

result:

ok correct

Test #90:

score: 0
Accepted
time: 48ms
memory: 221292kb

input:

40 887
?NA?AN?N?A?ANN??N?ANCAN?N????AC?NN?NA???

output:

NNANANANAAAANNCANAANCANCNCACCACCNNCNACCC

result:

ok correct

Test #91:

score: 0
Accepted
time: 63ms
memory: 221300kb

input:

40 1310
CCN?NNANC??CANN??NC?N??NA?NNNNCN?N?CCCCC

output:

-1

result:

ok correct

Test #92:

score: 0
Accepted
time: 45ms
memory: 221136kb

input:

40 1568
ANCN?N?NACC??NNN?AAC?AANA?CA?NC?CNNAN??N

output:

-1

result:

ok correct

Test #93:

score: 0
Accepted
time: 53ms
memory: 221172kb

input:

40 2035
CA?N?ACCNN??CANA?NC?NACNC??CC???NCA?N?AC

output:

-1

result:

ok correct

Test #94:

score: 0
Accepted
time: 48ms
memory: 221216kb

input:

40 126
AC?CACCCN???C?NCCN?NN??CN?CNCN?C?N?C?A?C

output:

ACACACCCNACACANCCNXNNCACNCCNCNCCCNCCCACC

result:

ok correct

Test #95:

score: 0
Accepted
time: 43ms
memory: 221224kb

input:

40 962
CCC???A??????AN?N???C?NN??CANA?CNA??N???

output:

CCCNNNANNANANANANAAACCNNAACANACCNACCNCCC

result:

ok correct

Test #96:

score: 0
Accepted
time: 48ms
memory: 221176kb

input:

40 1043
?A??NANA?CN?N?AN?ANN?CNAANCC??AAANNN????

output:

-1

result:

ok correct

Test #97:

score: 0
Accepted
time: 57ms
memory: 221136kb

input:

40 1638
N?ANA?NA???A??N?CNNAA???NC????CNN??AC??N

output:

-1

result:

ok correct

Test #98:

score: 0
Accepted
time: 55ms
memory: 221156kb

input:

40 2240
NNC??NCA???N?N?NNC??CNNNAN??C?AN??AC?C??

output:

-1

result:

ok correct

Test #99:

score: 0
Accepted
time: 43ms
memory: 221296kb

input:

40 55
N?NCNC????C?A??A?A?NN??ACC??C??NC???ACN?

output:

-1

result:

ok correct

Test #100:

score: 0
Accepted
time: 43ms
memory: 221336kb

input:

40 639
C???NN??C?N?N????N?CA?NCAN????AN????NA??

output:

CAANNNAACANANAACCNACACNCANCCCCANCCCCNACC

result:

ok correct

Test #101:

score: 0
Accepted
time: 51ms
memory: 221188kb

input:

40 1438
?C?A?NA?AN???CA???NAAAN??A?NNANNCAA?????

output:

-1

result:

ok correct

Test #102:

score: 0
Accepted
time: 36ms
memory: 221188kb

input:

40 1660
???C?A???????NN??AANNAC???A?CN??ACN?AC?C

output:

-1

result:

ok correct

Test #103:

score: 0
Accepted
time: 55ms
memory: 221132kb

input:

40 2016
??AA??N?N??A?C?C????????C????C?C?CN??N?A

output:

-1

result:

ok correct

Test #104:

score: 0
Accepted
time: 51ms
memory: 221136kb

input:

40 242
?C???A???AA??A??C?CN???C???A?ANA?NN??AA?

output:

NCAAAAAAAAAACAACCCCNCCCCCCCACANACNNCCAAC

result:

ok correct

Test #105:

score: 0
Accepted
time: 51ms
memory: 221152kb

input:

40 711
??A?AA?C??C???CCNA?????C????A?????A??C??

output:

NNANAAACAACACACCNACCCCCCCCACACCCCCACCCCC

result:

ok correct

Test #106:

score: 0
Accepted
time: 67ms
memory: 221332kb

input:

40 1094
??AACN??N?A?????C????AA??CC???CC?N?A????

output:

NNAACNANNAAAAAAACACCAAACCCCCCCCCCNCACCCC

result:

ok correct

Test #107:

score: 0
Accepted
time: 48ms
memory: 221128kb

input:

40 1878
?A??AACCA????N???A???C?C?C??C?NANC?N?NAC

output:

-1

result:

ok correct

Test #108:

score: 0
Accepted
time: 53ms
memory: 221356kb

input:

40 2082
AC??ACANC?CN?C?N???C?N???N??C?CC?????C?C

output:

-1

result:

ok correct

Test #109:

score: 0
Accepted
time: 51ms
memory: 221228kb

input:

40 268
N?N??NNNCNC??CAC????A?C?????N???AN??NC??

output:

NANXXNNNCNCXXCACCCCCACCCCCCCNCCCANCCNCCC

result:

ok correct

Test #110:

score: 0
Accepted
time: 63ms
memory: 221148kb

input:

40 960
?????????N???NA?????????C??AC???AN?A???A

output:

NNAANAAAANAAANAAAAAAACCCCCCACCCCANCACCCA

result:

ok correct

Test #111:

score: 0
Accepted
time: 59ms
memory: 221216kb

input:

40 1342
???C?????C?????NA?N??N?C?????A?N???NA???

output:

NNNCNNNNNCNAAANNAANAANACAACCCACNCCCNACCC

result:

ok correct

Test #112:

score: 0
Accepted
time: 59ms
memory: 221336kb

input:

40 1739
?A?A???A???N?A??N???C???NCC??C??ANN???A?

output:

-1

result:

ok correct

Test #113:

score: 0
Accepted
time: 67ms
memory: 221280kb

input:

40 2484
??????N????N?????N?C??N????????????A???N

output:

-1

result:

ok correct

Test #114:

score: 0
Accepted
time: 60ms
memory: 221136kb

input:

40 116
?CN????????A??A???C????????????????C????

output:

ACNACCACCCCACCACCCCCCCCCCCCCCCCCCCCCCCCC

result:

ok correct

Test #115:

score: 0
Accepted
time: 54ms
memory: 221188kb

input:

40 538
NC???N?????????????NN??N????????CC???N??

output:

NCAAANAAAAAAAACCCCCNNAANCACCCCCCCCCCCNCC

result:

ok correct

Test #116:

score: 0
Accepted
time: 64ms
memory: 221140kb

input:

40 1128
?????AN?????CN????N?A????C???C??????????

output:

NNNAAANAAAAACNACACNAAACCCCCCCCCCCCCCCCCC

result:

ok correct

Test #117:

score: 0
Accepted
time: 72ms
memory: 221128kb

input:

40 1819
?????????C?AC?????C??A??NC?????????????C

output:

-1

result:

ok correct

Test #118:

score: 0
Accepted
time: 67ms
memory: 221128kb

input:

40 2198
??????A???N????????ANN???N?C??????C?????

output:

-1

result:

ok correct

Test #119:

score: 0
Accepted
time: 59ms
memory: 221280kb

input:

40 373
???????????C?A?????????A???A?C??????????

output:

NACANAACACCCAACCCCCCCCCACCCACCCCCCCCCCCC

result:

ok correct

Test #120:

score: 0
Accepted
time: 68ms
memory: 221152kb

input:

40 744
?????????????????C????????????A????C???N

output:

NNNAAAAAAAAACCCCCCCCCCACCCCCCCACCCCCCCCN

result:

ok correct

Test #121:

score: 0
Accepted
time: 67ms
memory: 221144kb

input:

40 1103
???????????????????????????N????????????

output:

NNNNAAAAAAAAAAACCACCCCCCCCCNACCCCCCCCCCC

result:

ok correct

Test #122:

score: 0
Accepted
time: 72ms
memory: 221292kb

input:

40 1866
???????A??????A??A???????????????C??????

output:

NNNNNNNAANAAAAAAAAAACCCCCCCCCACCCCCCCCCC

result:

ok correct

Test #123:

score: 0
Accepted
time: 60ms
memory: 221336kb

input:

40 2466
????????????CN?????????????????N??CA????

output:

-1

result:

ok correct

Test #124:

score: 0
Accepted
time: 71ms
memory: 221192kb

input:

40 1
?????????????????????????????????????NAC

output:

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAC

result:

ok correct