QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#209811 | #7107. Chaleur | PetroTarnavskyi# | WA | 684ms | 22068kb | C++17 | 1.7kb | 2023-10-10 17:44:04 | 2023-10-10 17:44:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
const int N = 1 << 17;
VI g[N];
int solve(int a, int b, VI vals)
{
int n = SZ(vals);
set<PII> vali;
FOR(i, 0, n)
vali.insert(MP(vals[i], i));
VI used(n, 0);
while(vali.begin()->F != vali.rbegin()->F)
{
int v = vali.begin()->S;
vali.erase(vali.begin());
used[v] = 1;
for(int to : g[v])
{
if(used[to])
continue;
vali.erase(MP(vals[to], to));
vals[to] += b;
vali.insert(MP(vals[to], to));
}
}
VI cnt(n, 0);
int all = 0;
for(auto [_, v] : vali)
{
all -= a;
for(int to : g[v])
{
if(used[to] == 0)
continue;
cnt[to] -= b;
}
}
int ans = 1;
FOR(i, 0, n)
{
if(used[i] == 1 && cnt[i] + all == SZ(vali) - 1)
ans++;
}
return ans;
}
void solve()
{
int n, m;
cin >> n >> m;
FOR(i, 0, m)
{
int a, b;
cin >> a >> b;
a--; b--;
g[a].PB(b);
g[b].PB(a);
}
VI vals(n);
FOR(i, 0, n)
vals[i] = SZ(g[i]);
cout << solve(0, -1, vals) << " ";
FOR(i, 0, n)
vals[i] = n - 1 - SZ(g[i]);
cout << solve(-1, 1, vals) << "\n";
FOR(i, 0, n)
g[i].clear();
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(15);
int t;
cin >> t;
while(t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 6724kb
input:
3 3 2 1 2 2 3 6 6 1 2 2 3 1 3 1 4 2 5 3 6 4 1 1 2
output:
2 1 1 4 1 2
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 684ms
memory: 22068kb
input:
2231 1 0 5 7 4 1 3 4 3 1 3 5 4 2 3 2 4 5 5 4 2 1 2 5 2 4 2 3 5 10 3 2 2 5 1 4 4 2 4 5 1 2 1 3 3 5 3 4 1 5 5 10 1 3 2 4 1 4 5 2 2 3 1 5 5 4 1 2 3 4 5 3 5 9 2 5 3 5 2 3 2 1 4 3 3 1 4 1 4 5 2 4 5 4 4 2 4 1 4 5 4 3 5 9 4 1 4 5 3 4 2 4 2 1 3 1 2 5 3 5 3 2 5 4 2 5 2 3 2 1 2 4 5 9 5 2 1 3 4 3 1 2 5 4 4 2 5...
output:
1 1 3 1 4 1 1 1 1 1 2 1 4 1 2 1 4 1 2 1 2 1 3 1 4 1 4 1 1 1 2 1 4 1 1 1 1 1 1 1 3 1 4 1 4 1 4 1 3 1 3 1 4 1 4 1 2 1 4 1 4 1 1 1 1 1 2 1 4 1 4 1 4 1 3 1 2 1 4 1 2 1 4 1 4 1 4 1 3 1 1 1 4 1 4 1 1 1 2 1 4 1 2 1 2 1 1 1 4 1 1 1 3 1 4 1 1 1 2 1 1 1 3 1 3 1 1 1 3 1 3 1 2 1 1 1 4 1 3 1 1 1 2 1 3 1 2 1 2 1 ...
result:
wrong answer 4th lines differ - expected: '1 5', found: '1 1'