QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#364704#8110. Additionckiseki#WA 1ms3872kbC++202.9kb2024-03-24 16:09:222024-03-24 16:09:22

Judging History

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

  • [2024-03-24 16:09:22]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3872kb
  • [2024-03-24 16:09:22]
  • 提交

answer

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

#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
void debug_(auto s, auto ...a) {
  cerr << "\e[1;32m(" << s << ") = (";
  int f = 0;
  (..., (cerr << (f++ ? ", " : "") << a));
  cerr << ")\e[0m\n";
}
#include <experimental/iterator>
void orange_(auto s, auto L, auto R) {
  cerr << "\e[1;33m[ " << s << " ] = [ ";
  using namespace experimental;
  copy(L, R, make_ostream_joiner(cerr, ", "));
  cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);

  vector<pair<string, string>> cmd;

  for (string ab : {"A", "B"})
    for (string zo : {"0", "1"})
      cmd.emplace_back(ab + zo, zo + ab);

  cmd.emplace_back("+0", "+A");
  cmd.emplace_back("+1", "+B");

  for (string cd : {"C", "D"})
    for (string abzo : {"A", "B", "0", "1"})
      cmd.emplace_back(cd + abzo, abzo + cd);

  auto gao = [&](int carry, int x) {
    return (carry ? ","s : "+"s) + (x ? "D"s : "C"s);
  };

  for (string zo : {"0", "1"})
    for (string carry : {"+", ","})
      for (string ab : {"A", "B"}) {
        int a = zo[0] - '0';
        int b = ab[0] - 'A';
        int c = carry[0] - '+';
        int x = (a + b + c) & 1;
        int nc = (a + b + c) >= 2;
        cmd.emplace_back(zo + carry + ab, gao(nc, x));
      }

  for (string carry : {"+", ","})
    for (string ab : {"A", "B"}) {
      int a = 0;
      int b = ab[0] - 'A';
      int c = carry[0] - '+';
      int x = (a + b + c) & 1;
      int nc = (a + b + c) >= 2;
      cmd.emplace_back(carry + ab, gao(nc, x));
    }

  for (string cd : {"C", "D"})
    for (string zo : {"0", "1"})
      for (string carry : {"+", ","}) {
        int a = zo[0] - '0';
        int b = 0;
        int c = carry[0] - '+';
        int x = (a + b + c) & 1;
        int nc = (a + b + c) >= 2;
        cmd.emplace_back(zo + carry + cd, gao(nc, x));
      }


  cmd.emplace_back(",C", "ZDC");
  cmd.emplace_back(",D", "ZDD");
  cmd.emplace_back("+C", "ZC");
  cmd.emplace_back("+D", "ZD");

  cmd.emplace_back("ZC", "0Z");
  cmd.emplace_back("ZD", "1Z");
  cmd.emplace_back("0Z", "0");
  cmd.emplace_back("1Z", "1");

  cout << cmd.size() << '\n';
  for (auto [a, b] : cmd)
    cout << a << ' ' << b << '\n';

  auto run = [&](string s) {
    while (true) {
      debug(s);
      bool found = false;
      for (auto [a, b] : cmd) {
        auto i = s.find(a);
        if (i != string::npos) {
          s = s.substr(0, i) + b + s.substr(i + a.size());
          found = true;
          break;
        }
      }
      if (!found)
        break;
    }
    return s;
  };

  debug( run("10+10") );
  debug( run("0+0") );
  debug( run("1+0") );
  debug( run("0+1") );
  debug( run("1+1") );

  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3848kb

input:

1

output:

42
A0 0A
A1 1A
B0 0B
B1 1B
+0 +A
+1 +B
CA AC
CB BC
C0 0C
C1 1C
DA AD
DB BD
D0 0D
D1 1D
0+A +C
0+B +D
0,A +D
0,B ,C
1+A +D
1+B ,C
1,A ,C
1,B ,D
+A +C
+B +D
,A +D
,B ,C
0+C +C
0,C +D
1+C +D
1,C ,C
0+D +C
0,D +D
1+D +D
1,D ,C
,C ZDC
,D ZDD
+C ZC
+D ZD
ZC 0Z
ZD 1Z
0Z 0
1Z 1

result:

ok OK!

Test #2:

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

input:

2

output:

42
A0 0A
A1 1A
B0 0B
B1 1B
+0 +A
+1 +B
CA AC
CB BC
C0 0C
C1 1C
DA AD
DB BD
D0 0D
D1 1D
0+A +C
0+B +D
0,A +D
0,B ,C
1+A +D
1+B ,C
1,A ,C
1,B ,D
+A +C
+B +D
,A +D
,B ,C
0+C +C
0,C +D
1+C +D
1,C ,C
0+D +C
0,D +D
1+D +D
1,D ,C
,C ZDC
,D ZDD
+C ZC
+D ZD
ZC 0Z
ZD 1Z
0Z 0
1Z 1

result:

ok OK!

Test #3:

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

input:

3

output:

42
A0 0A
A1 1A
B0 0B
B1 1B
+0 +A
+1 +B
CA AC
CB BC
C0 0C
C1 1C
DA AD
DB BD
D0 0D
D1 1D
0+A +C
0+B +D
0,A +D
0,B ,C
1+A +D
1+B ,C
1,A ,C
1,B ,D
+A +C
+B +D
,A +D
,B ,C
0+C +C
0,C +D
1+C +D
1,C ,C
0+D +C
0,D +D
1+D +D
1,D ,C
,C ZDC
,D ZDD
+C ZC
+D ZD
ZC 0Z
ZD 1Z
0Z 0
1Z 1

result:

ok OK!

Test #4:

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

input:

4

output:

42
A0 0A
A1 1A
B0 0B
B1 1B
+0 +A
+1 +B
CA AC
CB BC
C0 0C
C1 1C
DA AD
DB BD
D0 0D
D1 1D
0+A +C
0+B +D
0,A +D
0,B ,C
1+A +D
1+B ,C
1,A ,C
1,B ,D
+A +C
+B +D
,A +D
,B ,C
0+C +C
0,C +D
1+C +D
1,C ,C
0+D +C
0,D +D
1+D +D
1,D ,C
,C ZDC
,D ZDD
+C ZC
+D ZD
ZC 0Z
ZD 1Z
0Z 0
1Z 1

result:

ok OK!

Test #5:

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

input:

5

output:

42
A0 0A
A1 1A
B0 0B
B1 1B
+0 +A
+1 +B
CA AC
CB BC
C0 0C
C1 1C
DA AD
DB BD
D0 0D
D1 1D
0+A +C
0+B +D
0,A +D
0,B ,C
1+A +D
1+B ,C
1,A ,C
1,B ,D
+A +C
+B +D
,A +D
,B ,C
0+C +C
0,C +D
1+C +D
1,C ,C
0+D +C
0,D +D
1+D +D
1,D ,C
,C ZDC
,D ZDD
+C ZC
+D ZD
ZC 0Z
ZD 1Z
0Z 0
1Z 1

result:

ok OK!

Test #6:

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

input:

6

output:

42
A0 0A
A1 1A
B0 0B
B1 1B
+0 +A
+1 +B
CA AC
CB BC
C0 0C
C1 1C
DA AD
DB BD
D0 0D
D1 1D
0+A +C
0+B +D
0,A +D
0,B ,C
1+A +D
1+B ,C
1,A ,C
1,B ,D
+A +C
+B +D
,A +D
,B ,C
0+C +C
0,C +D
1+C +D
1,C ,C
0+D +C
0,D +D
1+D +D
1,D ,C
,C ZDC
,D ZDD
+C ZC
+D ZD
ZC 0Z
ZD 1Z
0Z 0
1Z 1

result:

ok OK!

Test #7:

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

input:

7

output:

42
A0 0A
A1 1A
B0 0B
B1 1B
+0 +A
+1 +B
CA AC
CB BC
C0 0C
C1 1C
DA AD
DB BD
D0 0D
D1 1D
0+A +C
0+B +D
0,A +D
0,B ,C
1+A +D
1+B ,C
1,A ,C
1,B ,D
+A +C
+B +D
,A +D
,B ,C
0+C +C
0,C +D
1+C +D
1,C ,C
0+D +C
0,D +D
1+D +D
1,D ,C
,C ZDC
,D ZDD
+C ZC
+D ZD
ZC 0Z
ZD 1Z
0Z 0
1Z 1

result:

ok OK!

Test #8:

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

input:

8

output:

42
A0 0A
A1 1A
B0 0B
B1 1B
+0 +A
+1 +B
CA AC
CB BC
C0 0C
C1 1C
DA AD
DB BD
D0 0D
D1 1D
0+A +C
0+B +D
0,A +D
0,B ,C
1+A +D
1+B ,C
1,A ,C
1,B ,D
+A +C
+B +D
,A +D
,B ,C
0+C +C
0,C +D
1+C +D
1,C ,C
0+D +C
0,D +D
1+D +D
1,D ,C
,C ZDC
,D ZDD
+C ZC
+D ZD
ZC 0Z
ZD 1Z
0Z 0
1Z 1

result:

ok OK!

Test #9:

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

input:

9

output:

42
A0 0A
A1 1A
B0 0B
B1 1B
+0 +A
+1 +B
CA AC
CB BC
C0 0C
C1 1C
DA AD
DB BD
D0 0D
D1 1D
0+A +C
0+B +D
0,A +D
0,B ,C
1+A +D
1+B ,C
1,A ,C
1,B ,D
+A +C
+B +D
,A +D
,B ,C
0+C +C
0,C +D
1+C +D
1,C ,C
0+D +C
0,D +D
1+D +D
1,D ,C
,C ZDC
,D ZDD
+C ZC
+D ZD
ZC 0Z
ZD 1Z
0Z 0
1Z 1

result:

ok OK!

Test #10:

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

input:

10

output:

42
A0 0A
A1 1A
B0 0B
B1 1B
+0 +A
+1 +B
CA AC
CB BC
C0 0C
C1 1C
DA AD
DB BD
D0 0D
D1 1D
0+A +C
0+B +D
0,A +D
0,B ,C
1+A +D
1+B ,C
1,A ,C
1,B ,D
+A +C
+B +D
,A +D
,B ,C
0+C +C
0,C +D
1+C +D
1,C ,C
0+D +C
0,D +D
1+D +D
1,D ,C
,C ZDC
,D ZDD
+C ZC
+D ZD
ZC 0Z
ZD 1Z
0Z 0
1Z 1

result:

ok OK!

Test #11:

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

input:

11

output:

42
A0 0A
A1 1A
B0 0B
B1 1B
+0 +A
+1 +B
CA AC
CB BC
C0 0C
C1 1C
DA AD
DB BD
D0 0D
D1 1D
0+A +C
0+B +D
0,A +D
0,B ,C
1+A +D
1+B ,C
1,A ,C
1,B ,D
+A +C
+B +D
,A +D
,B ,C
0+C +C
0,C +D
1+C +D
1,C ,C
0+D +C
0,D +D
1+D +D
1,D ,C
,C ZDC
,D ZDD
+C ZC
+D ZD
ZC 0Z
ZD 1Z
0Z 0
1Z 1

result:

ok OK!

Test #12:

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

input:

12

output:

42
A0 0A
A1 1A
B0 0B
B1 1B
+0 +A
+1 +B
CA AC
CB BC
C0 0C
C1 1C
DA AD
DB BD
D0 0D
D1 1D
0+A +C
0+B +D
0,A +D
0,B ,C
1+A +D
1+B ,C
1,A ,C
1,B ,D
+A +C
+B +D
,A +D
,B ,C
0+C +C
0,C +D
1+C +D
1,C ,C
0+D +C
0,D +D
1+D +D
1,D ,C
,C ZDC
,D ZDD
+C ZC
+D ZD
ZC 0Z
ZD 1Z
0Z 0
1Z 1

result:

ok OK!

Test #13:

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

input:

13

output:

42
A0 0A
A1 1A
B0 0B
B1 1B
+0 +A
+1 +B
CA AC
CB BC
C0 0C
C1 1C
DA AD
DB BD
D0 0D
D1 1D
0+A +C
0+B +D
0,A +D
0,B ,C
1+A +D
1+B ,C
1,A ,C
1,B ,D
+A +C
+B +D
,A +D
,B ,C
0+C +C
0,C +D
1+C +D
1,C ,C
0+D +C
0,D +D
1+D +D
1,D ,C
,C ZDC
,D ZDD
+C ZC
+D ZD
ZC 0Z
ZD 1Z
0Z 0
1Z 1

result:

ok OK!

Test #14:

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

input:

14

output:

42
A0 0A
A1 1A
B0 0B
B1 1B
+0 +A
+1 +B
CA AC
CB BC
C0 0C
C1 1C
DA AD
DB BD
D0 0D
D1 1D
0+A +C
0+B +D
0,A +D
0,B ,C
1+A +D
1+B ,C
1,A ,C
1,B ,D
+A +C
+B +D
,A +D
,B ,C
0+C +C
0,C +D
1+C +D
1,C ,C
0+D +C
0,D +D
1+D +D
1,D ,C
,C ZDC
,D ZDD
+C ZC
+D ZD
ZC 0Z
ZD 1Z
0Z 0
1Z 1

result:

ok OK!

Test #15:

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

input:

15

output:

42
A0 0A
A1 1A
B0 0B
B1 1B
+0 +A
+1 +B
CA AC
CB BC
C0 0C
C1 1C
DA AD
DB BD
D0 0D
D1 1D
0+A +C
0+B +D
0,A +D
0,B ,C
1+A +D
1+B ,C
1,A ,C
1,B ,D
+A +C
+B +D
,A +D
,B ,C
0+C +C
0,C +D
1+C +D
1,C ,C
0+D +C
0,D +D
1+D +D
1,D ,C
,C ZDC
,D ZDD
+C ZC
+D ZD
ZC 0Z
ZD 1Z
0Z 0
1Z 1

result:

ok OK!

Test #16:

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

input:

16

output:

42
A0 0A
A1 1A
B0 0B
B1 1B
+0 +A
+1 +B
CA AC
CB BC
C0 0C
C1 1C
DA AD
DB BD
D0 0D
D1 1D
0+A +C
0+B +D
0,A +D
0,B ,C
1+A +D
1+B ,C
1,A ,C
1,B ,D
+A +C
+B +D
,A +D
,B ,C
0+C +C
0,C +D
1+C +D
1,C ,C
0+D +C
0,D +D
1+D +D
1,D ,C
,C ZDC
,D ZDD
+C ZC
+D ZD
ZC 0Z
ZD 1Z
0Z 0
1Z 1

result:

ok OK!

Test #17:

score: -100
Wrong Answer
time: 1ms
memory: 3580kb

input:

17

output:

42
A0 0A
A1 1A
B0 0B
B1 1B
+0 +A
+1 +B
CA AC
CB BC
C0 0C
C1 1C
DA AD
DB BD
D0 0D
D1 1D
0+A +C
0+B +D
0,A +D
0,B ,C
1+A +D
1+B ,C
1,A ,C
1,B ,D
+A +C
+B +D
,A +D
,B ,C
0+C +C
0,C +D
1+C +D
1,C ,C
0+D +C
0,D +D
1+D +D
1,D ,C
,C ZDC
,D ZDD
+C ZC
+D ZD
ZC 0Z
ZD 1Z
0Z 0
1Z 1

result:

wrong answer Zla odpowiedz. Oczekiwano 10, a wczytano 1