Submission #63280847


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
int n, m, x;
vector<pair<int, int>> edges[400200];
long long dist[400200];
priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> q;
int main() {
scanf ("%d%d%d", &n, &m, &x);
for (int i = 1; i <= m; ++i) {
int u, v;
scanf ("%d%d", &u, &v);
edges[u].push_back (make_pair (v, 1));
edges[n + v].push_back (make_pair (n + u, 1));
}
for (int i = 1; i <= n; ++i) {
edges[i].push_back (make_pair (n + i, x));
edges[n + i].push_back (make_pair (i, x));
}
memset (dist, 127, sizeof (dist));
dist[1] = 0;
q.push (make_pair (0, 1));
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
using namespace std;
int n, m, x;
vector<pair<int, int>> edges[400200];
long long dist[400200];
priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> q;
int main() {
	scanf ("%d%d%d", &n, &m, &x);
	for (int i = 1; i <= m; ++i) {
		int u, v;
		scanf ("%d%d", &u, &v);
		edges[u].push_back (make_pair (v, 1));
		edges[n + v].push_back (make_pair (n + u, 1));
	}
	for (int i = 1; i <= n; ++i) {
		edges[i].push_back (make_pair (n + i, x));
		edges[n + i].push_back (make_pair (i, x));
	}
	memset (dist, 127, sizeof (dist));
	dist[1] = 0;
	q.push (make_pair (0, 1));
	while (!q.empty ()) {
		long long dst = q.top ().first;
		int u = q.top ().second;
		q.pop ();
		for (auto [v, w] : edges[u]) {
			if (dst + w < dist[v]) {
				dist[v] = dst + w;
				q.push (make_pair (dst + w, v));
			}
		}
	}
	printf ("%lld\n", min (dist[n], dist[n + n]));
	return 0;
}

Submission Info

Submission Time
Task E - Flip Edge
User HappyDavid3367
Language C++ 20 (gcc 12.2)
Score 425
Code Size 955 Byte
Status AC
Exec Time 246 ms
Memory 34024 KB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:8:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf ("%d%d%d", &n, &m, &x);
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:11:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |                 scanf ("%d%d", &u, &v);
      |                 ~~~~~~^~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 425 / 425
Status
AC × 4
AC × 70
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 01_random_39.txt, 01_random_40.txt, 01_random_41.txt, 01_random_42.txt, 01_random_43.txt, 01_random_44.txt, 01_random_45.txt, 01_random_46.txt, 01_random_47.txt, 01_random_48.txt, 01_random_49.txt, 01_random_50.txt, 01_random_51.txt, 01_random_52.txt, 01_random_53.txt, 01_random_54.txt, 01_random_55.txt, 01_random_56.txt, 01_random_57.txt, 01_random_58.txt, 01_random_59.txt, 01_random_60.txt, 01_random_61.txt, 01_random_62.txt, 01_random_63.txt, 01_random_64.txt, 01_random_65.txt, 01_random_66.txt, 01_random_67.txt, 01_random_68.txt, 01_random_69.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 4 ms 6824 KB
00_sample_01.txt AC 4 ms 6904 KB
00_sample_02.txt AC 4 ms 6824 KB
00_sample_03.txt AC 4 ms 6888 KB
01_random_04.txt AC 244 ms 32200 KB
01_random_05.txt AC 191 ms 31692 KB
01_random_06.txt AC 217 ms 30600 KB
01_random_07.txt AC 246 ms 32196 KB
01_random_08.txt AC 192 ms 31672 KB
01_random_09.txt AC 232 ms 30624 KB
01_random_10.txt AC 237 ms 32324 KB
01_random_11.txt AC 179 ms 31764 KB
01_random_12.txt AC 215 ms 30372 KB
01_random_13.txt AC 235 ms 32272 KB
01_random_14.txt AC 169 ms 31604 KB
01_random_15.txt AC 217 ms 30404 KB
01_random_16.txt AC 231 ms 32164 KB
01_random_17.txt AC 177 ms 31664 KB
01_random_18.txt AC 225 ms 30436 KB
01_random_19.txt AC 224 ms 32276 KB
01_random_20.txt AC 176 ms 31772 KB
01_random_21.txt AC 224 ms 30432 KB
01_random_22.txt AC 236 ms 31188 KB
01_random_23.txt AC 177 ms 31608 KB
01_random_24.txt AC 238 ms 30504 KB
01_random_25.txt AC 232 ms 31184 KB
01_random_26.txt AC 194 ms 31688 KB
01_random_27.txt AC 227 ms 30492 KB
01_random_28.txt AC 232 ms 32204 KB
01_random_29.txt AC 185 ms 31652 KB
01_random_30.txt AC 230 ms 30632 KB
01_random_31.txt AC 158 ms 23712 KB
01_random_32.txt AC 36 ms 12532 KB
01_random_33.txt AC 95 ms 18564 KB
01_random_34.txt AC 164 ms 29616 KB
01_random_35.txt AC 74 ms 16660 KB
01_random_36.txt AC 105 ms 20192 KB
01_random_37.txt AC 82 ms 15476 KB
01_random_38.txt AC 56 ms 24652 KB
01_random_39.txt AC 93 ms 18440 KB
01_random_40.txt AC 147 ms 27704 KB
01_random_41.txt AC 94 ms 27424 KB
01_random_42.txt AC 21 ms 10080 KB
01_random_43.txt AC 154 ms 26704 KB
01_random_44.txt AC 48 ms 18352 KB
01_random_45.txt AC 209 ms 29632 KB
01_random_46.txt AC 165 ms 30228 KB
01_random_47.txt AC 151 ms 33940 KB
01_random_48.txt AC 159 ms 30332 KB
01_random_49.txt AC 151 ms 34000 KB
01_random_50.txt AC 166 ms 30328 KB
01_random_51.txt AC 133 ms 33944 KB
01_random_52.txt AC 160 ms 30332 KB
01_random_53.txt AC 155 ms 33944 KB
01_random_54.txt AC 176 ms 30324 KB
01_random_55.txt AC 149 ms 34024 KB
01_random_56.txt AC 186 ms 31824 KB
01_random_57.txt AC 176 ms 31736 KB
01_random_58.txt AC 193 ms 31796 KB
01_random_59.txt AC 182 ms 28584 KB
01_random_60.txt AC 184 ms 28664 KB
01_random_61.txt AC 189 ms 28724 KB
01_random_62.txt AC 133 ms 24412 KB
01_random_63.txt AC 132 ms 24456 KB
01_random_64.txt AC 121 ms 24348 KB
01_random_65.txt AC 4 ms 6904 KB
01_random_66.txt AC 4 ms 6792 KB
01_random_67.txt AC 4 ms 6764 KB
01_random_68.txt AC 21 ms 27076 KB
01_random_69.txt AC 12 ms 15956 KB


2025-03-26 (Wed)
16:05:23 +00:00