QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#637485#8058. Binary vs Ternaryucup-team073#WA 2ms3896kbC++203.2kb2024-10-13 13:02:562024-10-13 13:02:57

Judging History

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

  • [2024-10-13 13:02:57]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3896kb
  • [2024-10-13 13:02:56]
  • 提交

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,n+1);
    ++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: 100
Accepted
time: 0ms
memory: 3896kb

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
4 5
4 5
4 5
5 6
5 6
5 6
6 7
1 2
2 4

result:

ok Haitang Suki (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3536kb

input:

1000
11100
111
1
11110
10001
10
1011
1111
10
1110
1100
11
11010
11
110
11
1
10001
10110
10
10
11111
10000
1001
10
1
11
10111
11
10
1
100
11
10100
1
10
101
11
1100
110
11
1110
1
1001
1
11111
10
10010
10
11001
110
1010
10011
1110
10100
1001
1001
101
100
1
1001
11
101
11
101
1001
1
1
1011
1
10
10
1011
...

output:

6
3 4
4 5
1 2
2 4
1 2
2 4
-1
13
1 2
2 3
3 4
1 2
2 4
1 2
2 4
1 2
2 4
1 2
1 2
1 2
2 4
6
1 2
3 4
3 4
4 5
1 2
2 4
11
1 2
1 2
1 2
2 3
2 3
2 3
3 4
3 4
3 4
1 2
2 4
6
2 3
3 4
1 2
2 4
1 2
2 4
8
2 3
4 5
1 2
2 4
1 2
2 4
1 2
2 4
3
2 3
1 2
2 4
-1
12
1 2
4 5
1 2
2 4
1 2
2 4
1 2
2 4
1 2
1 2
1 2
2 4
15
1 2
1 2
1 2
...

result:

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