Submission #10443589
Source Code Expand
Copy
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;
const int maxN = 1 << 17;
vector <int> G[maxN], comp;
int res[maxN], compId[maxN], compCtr;
pair <int, int> H[maxN];
void dfs(int v)
{
compId[v] = compCtr;
comp.pb(v);
for (int u : G[v])
if (compId[u] == 0)
dfs(u);
}
void solve()
{
int n, m, k;
scanf ("%d%d%d", &n, &m, &k);
FOR(i, 0, m)
{
int a, b;
scanf ("%d%d", &a, &b);
G[a].pb(b);
G[b].pb(a);
}
FOR(i, 1, n+1) if (compId[i] == 0)
{
comp.resize(0);
compCtr++;
dfs(i);
for (int v : comp)
res[v] = comp.size() - 1 - G[v].size();
}
while (k--)
{
int a, b;
scanf ("%d%d", &a, &b);
if (compId[a] == compId[b])
res[a]--, res[b]--;
}
FOR(i, 1, n+1)
printf("%d ", res[i]);
printf("\n");
}
int main()
{
int t;
t = 1;//scanf ("%d", &t);
while (t--)
solve();
return 0;
}
Submission Info
Submission Time |
|
Task |
D - Friend Suggestions |
User |
bgrm |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
1340 Byte |
Status |
AC |
Exec Time |
66 ms |
Memory |
8692 KB |
Compile Error
./Main.cpp: In function ‘void solve()’:
./Main.cpp:37:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf ("%d%d%d", &n, &m, &k);
^
./Main.cpp:41:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf ("%d%d", &a, &b);
^
./Main.cpp:58:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf ("%d%d", &a, &b);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
400 / 400 |
Status |
|
|
Set Name |
Test Cases |
Sample |
00-sample-00, 00-sample-01, 00-sample-02 |
All |
00-sample-00, 00-sample-01, 00-sample-02, 01-handmade-00, 01-handmade-01, 01-handmade-02, 01-handmade-03, 01-handmade-04, 01-handmade-05, 01-handmade-06, 02-small-00, 02-small-01, 02-small-02, 02-small-03, 02-small-04, 02-small-05, 02-small-06, 02-small-07, 02-small-08, 02-small-09, 03-large-00, 03-large-01, 03-large-02, 03-large-03, 03-large-04, 03-large-05, 03-large-06, 03-large-07, 03-large-08, 03-large-09 |
Case Name |
Status |
Exec Time |
Memory |
00-sample-00 |
AC |
3 ms |
3328 KB |
00-sample-01 |
AC |
3 ms |
3328 KB |
00-sample-02 |
AC |
3 ms |
3328 KB |
01-handmade-00 |
AC |
3 ms |
3328 KB |
01-handmade-01 |
AC |
3 ms |
3328 KB |
01-handmade-02 |
AC |
33 ms |
6780 KB |
01-handmade-03 |
AC |
18 ms |
3968 KB |
01-handmade-04 |
AC |
66 ms |
8444 KB |
01-handmade-05 |
AC |
55 ms |
8692 KB |
01-handmade-06 |
AC |
46 ms |
5760 KB |
02-small-00 |
AC |
3 ms |
3328 KB |
02-small-01 |
AC |
3 ms |
3328 KB |
02-small-02 |
AC |
3 ms |
3328 KB |
02-small-03 |
AC |
3 ms |
3328 KB |
02-small-04 |
AC |
3 ms |
3328 KB |
02-small-05 |
AC |
3 ms |
3328 KB |
02-small-06 |
AC |
3 ms |
3328 KB |
02-small-07 |
AC |
3 ms |
3328 KB |
02-small-08 |
AC |
3 ms |
3328 KB |
02-small-09 |
AC |
3 ms |
3328 KB |
03-large-00 |
AC |
45 ms |
6396 KB |
03-large-01 |
AC |
52 ms |
7420 KB |
03-large-02 |
AC |
47 ms |
7036 KB |
03-large-03 |
AC |
45 ms |
6908 KB |
03-large-04 |
AC |
45 ms |
6780 KB |
03-large-05 |
AC |
44 ms |
6912 KB |
03-large-06 |
AC |
41 ms |
6268 KB |
03-large-07 |
AC |
50 ms |
6912 KB |
03-large-08 |
AC |
57 ms |
8056 KB |
03-large-09 |
AC |
65 ms |
8444 KB |