QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#132994#6628. Flip it and Stick ittatyam#1 3ms3908kbC++171017b2023-08-01 12:47:182024-07-04 01:04:17

Judging History

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

  • [2024-07-04 01:04:17]
  • 评测
  • 测评结果:1
  • 用时:3ms
  • 内存:3908kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-01 12:47:18]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define all(a) begin(a), end(a)

/*
    0 => jimei
    00 => 00 wo kirihanasu
    haji no 1 wo yoseru
     or 11 wo kirihanasu
    01 => 11111000000
     hidari no 0 to migi no 1 de reverse
    000 => 000+ wo kirihanasu
    1 ga tarinaku naru toki ha kisuu ko no 0 wo kuttukeru
    001 => 1111101101010111000000
     00+ wo migi ni
    010 => 111111001101110001100111111
     chuuou no 1 to 1 wo kuttukeru
*/
int count(const string& S, char c) {
    return count(all(S), c);
}
string reversed(string S) {
    reverse(all(S));
    return S;
}
int solve() {
    string S, T;
    cin >> S >> T;
    if(count(T, '1') > count(T, '0')) {
        for(char& c : S) c ^= 1;
        for(char& c : T) c ^= 1;
    }
    if(T > reversed(T)) {
        S = reversed(S);
        T = reversed(T);
    }
    if(T == "0") {
        if(count(S, '0')) return -1;
        return 0;
    }
    return 0;
}
int main() {
    cout << solve() << endl;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 1
Accepted

Test #1:

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

input:

1
0

output:

0

result:

ok 1 number(s): "0"

Test #2:

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

input:

1
1

output:

-1

result:

ok 1 number(s): "-1"

Test #3:

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

input:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

-1

result:

ok 1 number(s): "-1"

Test #4:

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

input:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

0

result:

ok 1 number(s): "0"

Test #5:

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

input:

101001000011101010101001001010010110111111001100110001111101111110110110101011111010001101111001101101010111101100000110001110001100000101111100000110111110001010101101101110001000011010000101000110110010110110100001110001111001010000000010000000101000000100110011101110100111111101111111111110010101...

output:

-1

result:

ok 1 number(s): "-1"

Test #6:

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

input:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

0

result:

ok 1 number(s): "0"

Test #7:

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

input:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

-1

result:

ok 1 number(s): "-1"

Subtask #2:

score: 0
Wrong Answer

Test #8:

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

input:

0
01

output:

0

result:

ok 1 number(s): "0"

Test #9:

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

input:

0
10

output:

0

result:

ok 1 number(s): "0"

Test #10:

score: -3
Wrong Answer
time: 0ms
memory: 3532kb

input:

01
01

output:

0

result:

wrong answer 1st numbers differ - expected: '1', found: '0'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Wrong Answer

Test #40:

score: 5
Accepted
time: 0ms
memory: 3788kb

input:

11
011

output:

0

result:

ok 1 number(s): "0"

Test #41:

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

input:

0
110

output:

0

result:

ok 1 number(s): "0"

Test #42:

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

input:

01
100

output:

0

result:

ok 1 number(s): "0"

Test #43:

score: -5
Wrong Answer
time: 0ms
memory: 3748kb

input:

110
110

output:

0

result:

wrong answer 1st numbers differ - expected: '1', found: '0'

Subtask #5:

score: 0
Wrong Answer

Test #53:

score: 5
Accepted
time: 0ms
memory: 3588kb

input:

11
011

output:

0

result:

ok 1 number(s): "0"

Test #54:

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

input:

01
100

output:

0

result:

ok 1 number(s): "0"

Test #55:

score: -5
Wrong Answer
time: 0ms
memory: 3468kb

input:

011
011

output:

0

result:

wrong answer 1st numbers differ - expected: '1', found: '0'

Subtask #6:

score: 0
Skipped

Dependency #4:

0%