Submission #19723394


Source Code Expand

Copy
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#define LL long long
#define LD long double
#define DB double
using namespace std;
const int MAXN = 2e6 + 5;
int n, ans;
int a[MAXN], b[MAXN], c[MAXN];
int d[MAXN], vis[MAXN];

int main() {
#ifdef IN
	freopen ("x.in", "r", stdin);
	freopen ("x.out", "w", stdout);
#endif
	int i,j,k;
	scanf ("%d", &n);
	for (i=1; i<=n; ++i)
		scanf ("%d%d", &a[i], &b[i]), ++c[a[i]], ++c[b[i]];
	for (i=1; i<=n; ++i) {
		if (c[ a[i] ] == 1) ++ans, d[a[i]] = vis[i] = 1;
		else if (c[ b[i] ] == 1) ++ans, d[b[i]] = vis[i] = 1;
	}
	for (i=1; i<=n; ++i)
		if (!vis[i]) {
			if (!d[ a[i] ]) ++ans, d[ a[i] ] = 1;
			else if (!d[ b[i] ]) ++ans, d[ b[i] ] = 1;
		}
	printf ("%d\n", ans);
	return 0;
}

Submission Info

Submission Time
Task B - Reversible Cards
User WAC
Language C++ (GCC 9.2.1)
Score 0
Code Size 824 Byte
Status WA
Exec Time 55 ms
Memory 9204 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:21:8: warning: unused variable ‘j’ [-Wunused-variable]
   21 |  int i,j,k;
      |        ^
./Main.cpp:21:10: warning: unused variable ‘k’ [-Wunused-variable]
   21 |  int i,j,k;
      |          ^
./Main.cpp:22:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   22 |  scanf ("%d", &n);
      |  ~~~~~~^~~~~~~~~~
./Main.cpp:24:9: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   24 |   scanf ("%d%d", &a[i], &b[i]), ++c[a[i]], ++c[b[i]];
      |   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 18
WA × 9
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt, 1_026.txt
Case Name Status Exec Time Memory
0_000.txt AC 11 ms 3652 KB
0_001.txt AC 2 ms 3572 KB
0_002.txt AC 4 ms 3812 KB
1_003.txt WA 2 ms 3808 KB
1_004.txt AC 2 ms 3624 KB
1_005.txt AC 38 ms 5280 KB
1_006.txt WA 2 ms 3732 KB
1_007.txt AC 3 ms 3616 KB
1_008.txt AC 38 ms 5380 KB
1_009.txt WA 55 ms 9176 KB
1_010.txt WA 54 ms 9036 KB
1_011.txt WA 53 ms 9204 KB
1_012.txt AC 47 ms 9176 KB
1_013.txt AC 47 ms 8388 KB
1_014.txt AC 48 ms 5268 KB
1_015.txt AC 43 ms 9092 KB
1_016.txt AC 3 ms 3580 KB
1_017.txt AC 14 ms 4140 KB
1_018.txt AC 27 ms 5036 KB
1_019.txt AC 49 ms 7712 KB
1_020.txt AC 50 ms 7644 KB
1_021.txt AC 2 ms 3752 KB
1_022.txt AC 2 ms 3812 KB
1_023.txt WA 45 ms 6776 KB
1_024.txt WA 27 ms 5768 KB
1_025.txt WA 49 ms 7640 KB
1_026.txt WA 26 ms 6316 KB