RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0701

Swap to Win

Bronze II 브론즈 II
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Farmer John has a favorite string \(t\) with \(M\) characters. He also has \(N\)
strings \(s_1, s_2, \ldots, s_N\) each with \(M\) characters
(\(1 \leq N, M \leq 1000\)).

FJ can perform the following two types of operations:

  1. FJ chooses any string \(s_x\) and two indices \(p\) and \(q\). Then, he swaps the \(p\)'th and \(q\)'th character of \(s_x\) (\(1\le x\le N, 1\le p,q\le M\)).
  2. FJ chooses two strings \(s_x\) and \(s_y\) and an index \(k\). Then, he swaps the \(k\)'th characters of \(s_x\) and \(s_y\) (\(1\le x,y\le N, 1\le k\le M\)).

His goal is to make \(s_1\) equal to \(t\). Find any series of operations that
fulfills his goal. Because FJ is in a hurry, he only has time to perform a total
of \(2M\) operations. The inputs guarantee that it is possible to fulfill FJ's
goal.

Problem credits: Chongtian Ma

제약

SCORING

  • Inputs 2-6: \(N, M \le 100\)
  • Inputs 7-12: No additional constraints.

Problem credits: Chongtian Ma

입력 형식

The first line contains \(T\) (\(1\le T\le 10\)), the number of independent tests.
Each test is specified in the following format:

The first line contains \(N\) and \(M\).

The second line contains \(t\).

Then, \(N\) lines follow, the \(i\)'th of which contains \(s_i\).

The inputs will guarantee that it is possible to fulfill FJ's goal. All strings
contain lowercase English letters (a-z).

출력 형식

The output for each test should be as follows:

On the first line, output an integer \(K\), the number of operations you will
perform. \(K\) must be a non-negative integer less than or equal to \(2M\).

Then, output \(K\) lines, denoting the operations you will perform in sequential
order. Each line should be one of the following:

  • \(\texttt{1 x p q}\)
  • \(\texttt{2 x y k}\)
예제 1
입력
3
3 6
banana
nabana
banana
nnbaaa
5 3
abc
def
bca
ghi
jkl
mno
3 5
abcde
abcde
abcde
zzzzz
출력
3
2 1 2 1
1 1 3 5
2 1 2 5
5
1 2 1 3
2 1 2 1
1 2 2 3
2 1 2 2
2 1 2 3
0
설명

Here is how \(s\) changes according to the first test's output (with letters
swapped in uppercase):

nabana    Babana    baNaBa    banaNa
banana -> Nanana -> nanana -> nanaBa
nnbaaa    nnbaaa    nnbaaa    nnbaaa

After all three operations, \(s_1=t\).

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2025-2026 > Third Contest > Bronze

태그

평가 및 의견

Swap to Win

개요
출제자 난이도 Bronze II 브론즈 II 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Swap to Win

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8