QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#637477#8058. Binary vs Ternaryucup-team073#WA 0ms3672kbC++203.2kb2024-10-13 13:01:052024-10-13 13:01:05

Judging History

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

  • [2024-10-13 13:01:05]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3672kb
  • [2024-10-13 13:01:05]
  • 提交

answer

#include<bits/stdc++.h>
#ifdef LOCAL
#define debug(...) printf(__VA_ARGS__)
#define edebug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#define edebug(...)
#endif
#define int ll
#define rep(i, x, y) for(int i = x; i <= y; ++i)
#define nrep(i, x, y) for(int i = x; i >= y; --i)
#define ll long long
#define pii std::pair<int,int>
#define pb emplace_back
#define fi first
#define se second
template <class T> 
inline void ckmax(T &a, T b) {
  if(a < b) a = b;
}
template <class T> 
inline void ckmin(T &a, T b) {
  if(a > b) a = b;
}
auto rt_YES = []{puts("YES");};
auto rt_Yes = []{puts("Yes");};
auto rt_NO = []{puts("NO");};
auto rt_No = []{puts("No");};
namespace IO {
#define isdigit(x) (x >= '0' && x <= '9')
  inline char gc() {
    return getchar();
  }
  inline bool blank(char ch) {
    return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
  }
  template <class T>
  inline void read(T &x) {
    double tmp = 1;
    bool sign = 0;
    x = 0;
    char ch = gc();
    for(; !isdigit(ch); ch = gc())
      if(ch == '-') sign = 1;
    for(; isdigit(ch); ch = gc())
      x = x * 10 + (ch - '0');
    if(ch == '.')
      for(ch = gc(); isdigit(ch); ch = gc())
        tmp /= 10.0, x += tmp * (ch - '0');
    if(sign) x = -x;
  }
  inline void read(char *s) {
    char ch = gc();
    for(; blank(ch); ch = gc());
    for(; !blank(ch); ch = gc())
      *s++ = ch;
    *s = 0;
  }
  inline void read(char &c) {
    for(c = gc(); blank(c); c = gc());
  }
  inline void push(const char &c) {
    putchar(c);
  }
  template <class T>
  inline void print(T x) {
    if(x < 0) {
      x = -x;
      push('-');
    }
    static T sta[35];
    T top = 0;
    do {
      sta[top++] = x % 10;
      x /= 10;
    } while(x);
    while(top)
      push(sta[--top] + '0');
  }
  template <class T>
  inline void print(T x, char lastChar) {
    print(x);
    push(lastChar);
  }
}
using namespace IO;

int a[200],b[200];
int n,m;
char A[200],B[200];
void solve(){
  std::vector<pii>ans;
  std::cin>>A>>B;
  n=strlen(A),m=strlen(B);
  rep(i,1,n)a[i]=A[i-1]-'0';
  rep(i,1,m)b[i]=B[i-1]-'0';
  if(n==1){
    if(m==1){puts("0\n");return;}
    else puts("-1");
    return;
  }
  rep(i,1,n)if(a[i]==0){
    ans.pb(i-1,i);
    a[i]=1;
  }
  int suma=n,sumb=0;
  rep(i,1,m)sumb+=b[i];
  while(suma<=sumb){
    ans.pb(n-1,n);
    ans.pb(n-1,n);
    ans.pb(n+1,n+2);
    ++n,++suma;
  }
  while(suma>sumb+1){
    ans.pb(1,2);
    ans.pb(2,4);
    --suma,--n;
  }
  int cur=m;
  nrep(i,n,2){
    int sum=0;
    while(b[cur]==0)++sum,--cur;
    --cur;
    rep(j,1,sum){
      ans.pb(i-1,i);
      ans.pb(i-1,i);
    }
  }
  ans.pb(1,2);
  ans.pb(2,4);
  print(ans.size(),'\n');
  for(auto[i,j]:ans)print(i,' '),print(j,'\n');
}

signed main() {
  clock_t c1 = clock();
#ifdef LOCAL
  freopen("in.in", "r", stdin);
  freopen("out.out", "w", stdout);
#endif
//------------------------------------------------------------------

  int t;read(t);while(t--)solve();

//------------------------------------------------------------------
end:
  std::cerr << "Time : " << clock() - c1 << " ms" << std::endl;
  return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3672kb

input:

3
1
111
110110
1101010
1111
111111

output:

-1
12
2 3
5 6
1 2
2 4
4 5
4 5
3 4
3 4
2 3
2 3
1 2
2 4
11
3 4
3 4
5 6
4 5
4 5
6 7
5 6
5 6
7 8
1 2
2 4

result:

wrong answer (l,r) is invalid (test case 3)