Submission #132605

# Submission time Handle Problem Language Result Execution time Memory
132605 2019-07-19T08:25:56 Z abra_stone None (KOI17_cat) C++14
10 / 100
334 ms 35320 KB
#include <iostream>
#include <cstdio>
#include <vector>
#define N 300005
using namespace std;

typedef long long ll;
ll n, m, ans, b;
vector<ll> gr[N];
bool v[N], v1[N];

ll f(ll p, ll pa) {
	ll i, ne, t;
	if (v[p]) return p;
	v[p] = 1;
	for (i = 0; i < gr[p].size(); i++) {
		ne = gr[p][i];
		if (ne != pa) {
			t = f(ne, p);
			if (t) return t;
		}
	}
	return 0;
}

bool g(ll p, ll pa) {
	ll i, ne, t;
	if (v1[p]) return 1;
	v1[p] = 1;
	for (i = 0; i < gr[p].size(); i++) {
		ne = gr[p][i];
		if (ne != pa && g(ne, p)) {
			ans += p;
			return 1;
		}
	}
	return 0;
}

int main()
{
	int i, t1, t2;
	cin >> n >> m;
	for (i = 0; i < n; i++) {
		scanf("%d %d", &t1, &t2);
		gr[t1].push_back(t2);
		gr[t2].push_back(t1);
	}
	g(f(1, 0), 0);
    cout << ans << endl;
    return 0;
}

Compilation message

cat.cpp: In function 'll f(ll, ll)':
cat.cpp:16:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < gr[p].size(); i++) {
              ~~^~~~~~~~~~~~~~
cat.cpp: In function 'bool g(ll, ll)':
cat.cpp:30:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < gr[p].size(); i++) {
              ~~^~~~~~~~~~~~~~
cat.cpp:27:12: warning: unused variable 't' [-Wunused-variable]
  ll i, ne, t;
            ^
cat.cpp: In function 'int main()':
cat.cpp:45:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &t1, &t2);
   ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 7416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 277 ms 21368 KB Output is correct
2 Correct 252 ms 23012 KB Output is correct
3 Correct 233 ms 23132 KB Output is correct
4 Correct 225 ms 23088 KB Output is correct
5 Correct 298 ms 23180 KB Output is correct
6 Correct 238 ms 23144 KB Output is correct
7 Correct 258 ms 23064 KB Output is correct
8 Correct 250 ms 23104 KB Output is correct
9 Correct 247 ms 23032 KB Output is correct
10 Correct 258 ms 23116 KB Output is correct
11 Correct 311 ms 23488 KB Output is correct
12 Correct 274 ms 23540 KB Output is correct
13 Correct 305 ms 23416 KB Output is correct
14 Correct 243 ms 23424 KB Output is correct
15 Correct 261 ms 23344 KB Output is correct
16 Correct 276 ms 26056 KB Output is correct
17 Correct 304 ms 26776 KB Output is correct
18 Correct 324 ms 26576 KB Output is correct
19 Correct 248 ms 26100 KB Output is correct
20 Correct 317 ms 25060 KB Output is correct
21 Correct 278 ms 24580 KB Output is correct
22 Correct 334 ms 29560 KB Output is correct
23 Correct 285 ms 30840 KB Output is correct
24 Correct 237 ms 23916 KB Output is correct
25 Correct 305 ms 30584 KB Output is correct
26 Correct 144 ms 35320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 139 ms 33624 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 7416 KB Output isn't correct
2 Halted 0 ms 0 KB -