Submission #19723581


Source Code Expand

Copy
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <vector>
#define LL long long
#define LD long double
#define DB double
#define mk(t1, t2) make_pair(t1, t2)
using namespace std;
const int MAXN = 2e6 + 5;
int n, ans;
int a[MAXN], b[MAXN], vis[MAXN];
pair<int, int> c[MAXN];
vector<int> cd[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<=4e5; ++i) c[i] = mk (0, i);
	for (i=1; i<=n; ++i) {
		scanf ("%d%d", &a[i], &b[i]);
		++c[a[i]].first, ++c[b[i]].first;
		cd[ a[i] ].push_back (i);
		cd[ b[i] ].push_back (i);
	}
	sort (c + 1, c + (int) 4e5 + 1);
	for (i=1; i<=4e5; ++i)
		if (c[i].first) break ;
	for (; i<=4e5; ++i) {
		int q = c[i].second;
		for (j = 0; j < cd[q].size(); ++j)
			if (!vis[ cd[q][j] ]) {
				++ans, vis[ cd[q][j] ] = 1;
				break ;
			}
	}
	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 1012 Byte
Status WA
Exec Time 176 ms
Memory 68408 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:38:17: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   38 |   for (j = 0; j < cd[q].size(); ++j)
      |               ~~^~~~~~~~~~~~~~
./Main.cpp:24:10: warning: unused variable ‘k’ [-Wunused-variable]
   24 |  int i,j,k;
      |          ^
./Main.cpp:25:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   25 |  scanf ("%d", &n);
      |  ~~~~~~^~~~~~~~~~
./Main.cpp:28:9: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   28 |   scanf ("%d%d", &a[i], &b[i]);
      |   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 14
WA × 13
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 85 ms 53720 KB
0_001.txt AC 48 ms 53644 KB
0_002.txt AC 83 ms 53692 KB
1_003.txt WA 82 ms 53780 KB
1_004.txt AC 81 ms 53688 KB
1_005.txt AC 108 ms 57332 KB
1_006.txt WA 81 ms 53712 KB
1_007.txt AC 83 ms 53792 KB
1_008.txt AC 111 ms 57512 KB
1_009.txt WA 174 ms 63956 KB
1_010.txt WA 169 ms 63828 KB
1_011.txt WA 176 ms 63960 KB
1_012.txt AC 102 ms 68408 KB
1_013.txt AC 105 ms 62368 KB
1_014.txt AC 87 ms 56520 KB
1_015.txt AC 96 ms 62800 KB
1_016.txt AC 81 ms 53564 KB
1_017.txt WA 64 ms 55020 KB
1_018.txt WA 78 ms 56580 KB
1_019.txt WA 141 ms 62272 KB
1_020.txt WA 139 ms 62332 KB
1_021.txt AC 80 ms 53776 KB
1_022.txt AC 81 ms 53780 KB
1_023.txt WA 126 ms 60464 KB
1_024.txt WA 93 ms 57748 KB
1_025.txt WA 144 ms 62360 KB
1_026.txt WA 114 ms 58692 KB