# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
132520 |
2019-07-19T05:40:54 Z |
sean617 |
None (KOI17_cat) |
C++ |
|
4 ms |
924 KB |
#include <iostream>
#include <cstdio>
#include <vector>
#define N 3005
using namespace std;
typedef long long ll;
ll n, m, k, s, v[N], cnt[N];
bool z, u[N];
vector<ll> a[N], k1, k2;
void f(ll p, ll q) {
ll i, num;
if (v[p] == k) {z = 1; return;}
v[p] = k;
for (i =0; i < a[p].size(); i++) {
num = a[p][i];
if (num == q || num == k) continue;
f(num, p);
}
}
int main()
{
ll i, j, t1, t2;
cin >> n >> m;
while (m--) {
scanf ("%lld %lld", &t1, &t2);
a[t1].push_back(t2);
a[t2].push_back(t1);
if (t1 > t2) swap(t1, t2);
if (t1 == t2 -1) u[t1] = 1;
else if (t1 == 1 && t2 == n) u[n] = 1;
else {
k1.push_back(t1);
k2.push_back(t2);
}
}
for (i = 1; i <= n; i++) {
if (!u[i]) break;
}
if (i > n) {
for (i = 0; i < k1.size(); i++) {
cnt[k1[i]]++;
cnt[k2[i]]++;
}
for (i = 1; i <= n; i++) {
if (cnt[i] == k1.size()) s += i;
}
cout << s;
return 0;
}
if (n <= 5000 && m <= 5000) {
for (k = 1; k <= n; k++) {
for (j = 1; j <= n; j++) {
if (v[j] == k || j == k) continue;
z = 0;
f(j, 0);
if (z) break;
}
if (j > n) s += k;
}
cout << s;
return 0;
}
cout << 0;
return 0;
}
Compilation message
cat.cpp: In function 'void f(ll, ll)':
cat.cpp:15:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i =0; i < a[p].size(); i++) {
~~^~~~~~~~~~~~~
cat.cpp: In function 'int main()':
cat.cpp:41:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (i = 0; i < k1.size(); i++) {
~~^~~~~~~~~~~
cat.cpp:46:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (cnt[i] == k1.size()) s += i;
~~~~~~~^~~~~~~~~~~~
cat.cpp:26:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf ("%lld %lld", &t1, &t2);
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Runtime error |
4 ms |
924 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
888 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Runtime error |
4 ms |
924 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Halted |
0 ms |
0 KB |
- |