QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#100441 | #4992. Enigmatic Enumeration | joesmitty | WA | 184ms | 3720kb | C++20 | 3.5kb | 2023-04-26 08:58:24 | 2023-04-26 08:58:27 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef vector<int> vi;
typedef vector< vector <int> > vvi;
typedef pair<int, int> pii;
typedef pair < pair < int, int >, int > piii;
typedef pair < pair <int, int > , pair <int, int> > piiii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
#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 all(a) a.begin(), a.end()
#define endl '\n';
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
template <typename T>
void pr(vector<T> &v) {
FOR(i, 0, sz(v)) cout << v[i] << " ";
cout << endl;
}
template <typename T>
void pr(vector<vector<T> > &v) {
FOR(i, 0, sz(v)) { pr(v[i]); }
}
template <typename T>
void re(T &x) {
cin >> x;
}
template <typename T>
void re(vector<T> &a) {
FOR(i, 0, sz(a)) re(a[i]);
}
template <class Arg, class... Args>
void re(Arg &first, Args &... rest) {
re(first);
re(rest...);
}
template <typename T>
void pr(T x) {
cout << x << endl;
}
template <class Arg, class... Args>
void pr(const Arg &first, const Args &... rest) {
cout << first << " ";
pr(rest...);
cout << endl;
}
void ps() { cout << endl; }
template<class T, class... Ts>
void ps(const T& t, const Ts&... ts) {
cout << t; if (sizeof...(ts)) cout << " "; ps(ts...);
}
const ll MOD = 998244353;
#define inf 1e18;
#define INF INT_MAX
long double PI = 4*atan(1);
long double eps = 1e-12;
vi adj[3010] = {};
vector<pii> edges;
int n,m;
vi minlen(3010, 1e8);
vi mincnt(3010, 0);
ll minv = 1e9;
ll minc = 0;
void bfs(int o, int b, vi &d) {
queue<pii> q;
d[o] = 0;
q.push({o,0});
while(!q.empty()) {
pii c = q.front(); q.pop();
int u = c.ff;
int dd = c.ss;
for(auto v : adj[u]) {
if(u == o && v == b) continue;
if(d[v] == 1e8) {
d[v] = dd + 1;
q.push({v, dd+1});
}
}
}
}
void rem(pii e) {
int o1 = e.ff;
int o2 = e.ss;
vi dist1(n, 1e8);
bfs(o1, o2, dist1);
vi dist2(n, 1e8);
bfs(o2, o1, dist2);
for(int i = 0; i < n; i++) {
if(i == o1 || i == o2) continue;
int d = dist1[i] + dist2[i];
if(d < 1e8) {
if(d < minv) {
minv = d;
minc = 1;
} else if(d == minv) {
minc++;
}
}
}
}
int main() {
auto start = chrono::high_resolution_clock::now();
ios_base::sync_with_stdio(0);cin.tie(0);
// ofstream cout("disrupt.out");
// ifstream cin("disrupt.in");
#ifdef DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
cin >> n >> m;
for(int i = 0; i < m; i++) {
int u,v;
cin >> u >> v; u--; v--;
adj[u].pb(v);
adj[v].pb(u);
edges.pb({u,v});
}
for(auto e : edges) {
rem(e);
}
cout << minc / ((minv - 1) * (minv + 1)) << endl;
// auto stop = chrono::high_resolution_clock::now();
// auto duration = chrono::duration_cast<chrono::microseconds>(stop - start);
// cout << duration.count() << endl;
//cin.close();
//cout.close();
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
input:
4 4 1 2 2 3 3 4 4 1
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 2ms
memory: 3508kb
input:
5 10 1 2 1 3 1 4 1 5 2 3 2 4 2 5 3 4 3 5 4 5
output:
10
result:
ok single line: '10'
Test #3:
score: 0
Accepted
time: 3ms
memory: 3520kb
input:
6 6 1 2 2 3 3 1 4 5 5 6 6 4
output:
2
result:
ok single line: '2'
Test #4:
score: 0
Accepted
time: 162ms
memory: 3720kb
input:
110 5995 109 20 100 23 99 65 106 40 105 62 89 67 57 9 83 38 38 20 28 11 39 28 32 20 108 90 96 50 97 51 80 40 64 48 101 27 84 27 43 35 103 79 70 32 29 28 109 2 43 16 110 94 101 71 84 67 23 19 33 17 107 79 90 33 83 64 57 39 105 46 47 1 80 79 93 67 78 53 34 20 105 15 77 66 65 63 102 57 76 59 47 40 95 4...
output:
215820
result:
ok single line: '215820'
Test #5:
score: 0
Accepted
time: 184ms
memory: 3656kb
input:
110 5985 50 38 109 70 110 85 50 23 71 51 52 2 43 32 74 28 98 13 103 94 108 54 41 12 55 12 51 10 44 2 56 35 8 6 27 2 72 19 92 65 64 42 31 20 110 67 74 46 93 57 59 5 63 50 33 31 98 42 75 59 103 87 81 79 99 20 100 84 89 87 87 78 67 56 85 74 14 7 103 16 42 41 29 13 68 26 110 7 91 63 86 78 86 85 44 42 10...
output:
214742
result:
ok single line: '214742'
Test #6:
score: -100
Wrong Answer
time: 159ms
memory: 3696kb
input:
154 5929 68 88 68 153 67 84 64 134 51 120 38 102 68 82 54 105 50 135 2 103 75 140 17 150 40 127 19 152 8 98 70 144 76 134 7 94 12 109 33 152 14 124 7 96 30 140 9 118 71 110 12 121 17 123 3 112 63 96 35 153 43 122 36 82 24 114 21 111 69 88 76 117 41 126 68 151 32 104 39 150 19 133 1 140 14 114 33 145...
output:
112651
result:
wrong answer 1st lines differ - expected: '8561476', found: '112651'