※ 글쓴이는 취미로 코딩을 익혀보는 사람이라 정확하지 않은 내용을 담고 있을 수 있다 ※

 

이번에 볼 문제는 백준 11121번 문제인 Communication Channel이다.
문제는 아래 링크를 확인하자.

https://www.acmicpc.net/problem/11121 

 

11121번: Communication Channels

The first line of the input consists of a single number T, the number of transmissions. Then follow T lines with the input and the output of each transmission as binary strings, separated by a single space. 0 < T ≤ 100 All inputs and outputs has length l

www.acmicpc.net

이 문제의 지문은 정보이론의 개요를 간략히 설명하고 있지만 그 대부분은 문제풀이와 상관이 없다. 이 문제가 요구하고 있는 작업은 단순히 매 테스트케이스마다 두 1과 0으로 이루어진 문자열이 주어질 때 그 둘이 같은지를 판단하는 것이다.

 

따라서 각 테스트케이스마다 두 문자열을 읽어 이 둘이 같은지 판단하는 것을 반복하는 것으로 문제를 해결할 수 있다.

 

아래는 제출한 소스코드이다.

#include <iostream>
#include <string>
using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int T; cin >> T;
	while (T--) {
		string s1, s2; cin >> s1 >> s2;
		if (s1 == s2) cout << "OK\n";
		else cout << "ERROR\n";
	}
}
728x90

+ Recent posts