Submission #22651652


Source Code Expand

Copy
#include <stdio.h>
int N;
char S[500009], T[500009];
int a[500009], cntA = 0;
int b[500009], cntB = 0;
int main() {
// Step #1.
scanf("%d", &N);
scanf("%s", S);
scanf("%s", T);
// Step #2. a[i], b[i]
for (int i = 0; i < N; i++) {
if (S[i] == '0') { a[cntA] = i; cntA += 1; }
if (T[i] == '0') { b[cntB] = i; cntB += 1; }
}
// Step #3.
if (cntA != cntB) {
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <stdio.h>

int N;
char S[500009], T[500009];
int a[500009], cntA = 0;
int b[500009], cntB = 0;

int main() {
	// Step #1. 入力
	scanf("%d", &N);
	scanf("%s", S);
	scanf("%s", T);

	// Step #2. a[i], b[i] を求める
	for (int i = 0; i < N; i++) {
		if (S[i] == '0') { a[cntA] = i; cntA += 1; }
		if (T[i] == '0') { b[cntB] = i; cntB += 1; }
	}

	// Step #3. 場合分け
	if (cntA != cntB) {
		printf("-1\n");
		return 0;
	}

	// Step #4. 答えを計算し、出力する
	int Answer = 0;
	for (int i = 0; i < cntA; i++) {
		if (a[i] != b[i]) Answer += 1;
	}
	printf("%d\n", Answer);
	return 0;
}

Submission Info

Submission Time
Task B - Electric Board
User E869120
Language C (GCC 9.2.1)
Score 500
Code Size 641 Byte
Status AC
Exec Time 19 ms
Memory 6560 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:10:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   10 |  scanf("%d", &N);
      |  ^~~~~~~~~~~~~~~
./Main.c:11:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   11 |  scanf("%s", S);
      |  ^~~~~~~~~~~~~~
./Main.c:12:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   12 |  scanf("%s", T);
      |  ^~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 4
AC × 30
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
in01.txt AC 4 ms 1664 KB
in02.txt AC 1 ms 1684 KB
in03.txt AC 1 ms 1644 KB
in04.txt AC 19 ms 6532 KB
in05.txt AC 9 ms 6560 KB
in06.txt AC 11 ms 6444 KB
in07.txt AC 12 ms 6132 KB
in08.txt AC 13 ms 5420 KB
in09.txt AC 13 ms 4612 KB
in10.txt AC 12 ms 3792 KB
in11.txt AC 8 ms 3040 KB
in12.txt AC 10 ms 2692 KB
in13.txt AC 10 ms 2652 KB
in14.txt AC 9 ms 2664 KB
in15.txt AC 18 ms 5820 KB
in16.txt AC 8 ms 4440 KB
in17.txt AC 1 ms 1744 KB
in18.txt AC 2 ms 1692 KB
in19.txt AC 14 ms 2696 KB
in20.txt AC 13 ms 4576 KB
in21.txt AC 12 ms 4560 KB
in22.txt AC 13 ms 4612 KB
in23.txt AC 13 ms 4584 KB
in24.txt AC 1 ms 1660 KB
in25.txt AC 3 ms 1644 KB
in26.txt AC 1 ms 1592 KB
sample_01.txt AC 1 ms 1744 KB
sample_02.txt AC 1 ms 1684 KB
sample_03.txt AC 2 ms 1636 KB
sample_04.txt AC 3 ms 1744 KB


2025-04-08 (Tue)
21:17:04 +00:00