#P98. Communicative Problem Test 1: The wrong bit

Communicative Problem Test 1: The wrong bit

Pinned Announcements

If you came from https://www.luogu.com.cn/problem/P12509, please read this section carefully.

The implementation of this problem's interactive library differs from P12509. AC codes are not interchangeable between these two problems.

However, this problem uses exactly the same test data as P12509. Neither problem uses adaptive judging.

For testing purposes, you may download the sample test data here: http://8.136.99.126/file/3/communicative_problem_sample.zip

In the test data, the input file contains string S\bm S and the output file contains the correct answer P\bm P.

Person in charge

Attention

This is a communicative problem.

You must strictly follow the submission guidelines!!!

Problem Description

Given two binary strings SS and TT of length nn that differ in at most one character:

  1. Program A reads binary string SS.
  2. Program A outputs a non-negative integer X2201X ≤ 2^{20}-1.
  3. Program B reads binary string TT and integer XX from Program A.
  4. Program B outputs the differing position between SS and TT.

Submission Format

Program A Template

Program A reads a length-nn binary string SS (without receiving nn) and outputs integer X2201X ≤ 2^{20}-1.

#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin >> S;
    int X = 0;
    // ...
    cout << X << endl;
    return 0;
}

Program B Template

Program B reads binary string TT and outputs integer XX from Program A It outputs position DD where SS and TT differ (output 00 if identical).

#include <bits/stdc++.h>
using namespace std;
int main()
{
    string T;
    int X;
    cin >> T >> X;
    int D = 0;
    // ...
    cout << D << endl;
    return 0;
}

Complete Template

// Paste Program A here

/* ATTENTION!!! THIS IS THE BARRIER!!! */

// Paste Program B here

Important Notes

  1. You must use this template exactly!
  2. Any attempt to attack the judge will be treated as cheating!
  3. Submission shouldn't exceed 10001000 lines and 10510^5 bytes.
  4. Compilation attributes: -O2 -std=c++14.
  5. Time limit: 1s per program; Memory limit: 512MB per program.

Constraints

1n1061 \le n \le 10^6.