QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#879568#9692. Currencyucup-team3099#WA 1ms3840kbC++205.4kb2025-02-02 06:18:442025-02-02 06:18:46

Judging History

This is the latest submission verdict.

  • [2025-02-02 06:18:46]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3840kb
  • [2025-02-02 06:18:44]
  • Submitted

answer

#ifdef LOCAL
#define _GLIBCXX_DEBUG 1
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

#if 0
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
 
    template<class T>
    using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, std::less<T>, __gnu_pbds::rb_tree_tag,
        __gnu_pbds::tree_order_statistics_node_update>;
#endif

#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <queue>
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <ctime> 
#include <cstring>
#include <random>
#include <chrono>
#include <cassert>
#include <climits>

using namespace std;
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)

#define each(a,x) for (auto& a: x)
#define tcT template<class T
#define tcTU tcT, class U
#define tcTUU tcT, class ...U
template<class T> using V = vector<T>; 
template<class T, size_t SZ> using AR = array<T,SZ>;

typedef string str;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
 
template<typename T, typename U> T &ctmax(T &x, const U &y){ return x = max<T>(x, y); }
template<typename T, typename U> T &ctmin(T &x, const U &y){ return x = min<T>(x, y); }
 
mt19937 rng((unsigned)chrono::steady_clock::now().time_since_epoch().count());
 
#define ts to_string
str ts(char c) { return str(1,c); }
str ts(bool b) { return b ? "true" : "false"; }
str ts(const char* s) { return (str)s; }
str ts(str s) { return s; }
str ts(vector<bool> v) { str res = "{"; F0R(i,sz(v)) res += char('0'+v[i]);	res += "}"; return res; }
template<size_t SZ> str ts(bitset<SZ> b) { str res = ""; F0R(i,SZ) res += char('0'+b[i]); return res; }
template<class A, class B> str ts(pair<A,B> p);
template<class T> str ts(T v) { bool fst = 1; str res = "{"; for (const auto& x: v) {if (!fst) res += ", ";	fst = 0; res += ts(x);}	res += "}"; return res;}
template<class A, class B> str ts(pair<A,B> p) {return "("+ts(p.first)+", "+ts(p.second)+")"; }
 
template<class A> void pr(A x) { cout << ts(x); }
template<class H, class... T> void pr(const H& h, const T&... t) { pr(h); pr(t...); }
void ps() { pr("\n"); }
template<class H, class... T> void ps(const H& h, const T&... t) { pr(h); if (sizeof...(t)) pr(" "); ps(t...); }
 
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {cerr << ts(h); if (sizeof...(t)) cerr << ", ";	DBG(t...); }

tcTU> void re(pair<T,U>& p);
tcT> void re(V<T>& v);
tcT, size_t SZ> void re(AR<T,SZ>& a);

tcT> void re(T& x) { cin >> x; }
void re(double& d) { str t; re(t); d = stod(t); }
void re(long double& d) { str t; re(t); d = stold(t); }
tcTUU> void re(T& t, U&... u) { re(t); re(u...); }

tcTU> void re(pair<T,U>& p) { re(p.first,p.second); }
tcT> void re(V<T>& x) { each(a,x) re(a); }
tcT, size_t SZ> void re(AR<T,SZ>& x) { each(a,x) re(a); }
tcT> void rv(int n, V<T>& x) { x.rsz(n); re(x); }

constexpr bool multitest() {return 0;}
void solve();
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int t = 1;
	if (multitest()) cin >> t;
	for (; t; t--) solve();
}






struct Dinic {
	struct Edge {
		int to, rev;
		ll c, oc;
		ll flow() { return max(oc - c, 0LL); } // if you need flows
	};
	vi lvl, ptr, q;
	vector<vector<Edge>> adj;
	Dinic(int n) : lvl(n), ptr(n), q(n), adj(n) {}
	void addEdge(int a, int b, ll c, ll rcap = 0) {
		adj[a].push_back({b, sz(adj[b]), c, c});
		adj[b].push_back({a, sz(adj[a]) - 1, rcap, rcap});
	}
	ll dfs(int v, int t, ll f) {
		if (v == t || !f) return f;
		for (int& i = ptr[v]; i < sz(adj[v]); i++) {
			Edge& e = adj[v][i];
			if (lvl[e.to] == lvl[v] + 1)
				if (ll p = dfs(e.to, t, min(f, e.c))) {
					e.c -= p, adj[e.to][e.rev].c += p;
					return p;
				}
		}
		return 0;
	}
	ll calc(int s, int t) {
		ll flow = 0; q[0] = s;
		rep(L,0,31) do { // 'int L=30' maybe faster for random data
			lvl = ptr = vi(sz(q));
			int qi = 0, qe = lvl[s] = 1;
			while (qi < qe && !lvl[t]) {
				int v = q[qi++];
				for (Edge e : adj[v])
					if (!lvl[e.to] && e.c >> (30 - L))
						q[qe++] = e.to, lvl[e.to] = lvl[v] + 1;
			}
			while (ll p = dfs(s, t, LLONG_MAX)) flow += p;
		} while (lvl[t]);
		return flow;
	}
	bool leftOfMinCut(int a) { return lvl[a] != 0; }
};

















void solve() {
	int n, m; re(n, m);

	int s = n;
	int t = n+1;
	Dinic flow(n+2);

	for (int i = 0; i+1 < n; i++) {
		int x; re(x);
		flow.addEdge(s, i, x);
	}

	int x; re(x);
	flow.addEdge(0, t, x);

	for (int i = 1; i+1 < n; i++) {
		int x; re(x);
		flow.addEdge(i, i+1, x, x);
	}

	re(x);
	flow.addEdge(s, n-2, x);

	for (int i = 0; i+1 < n; i++) {
		int x; re(x);
		flow.addEdge(i, t, x);
	}

	for (; m; m--) {
		int i, j, c; re(i, j, c);
		i--; j--;
		flow.addEdge(j, i, c);
	}

	ps(flow.calc(s,t));
}


















































	







詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3712kb

input:

5 2
2 3 5 2
6 1 2 1 1
1 2 4 2
1 4 4
2 3 1

output:

13

result:

ok 1 number(s): "13"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

6 1000
601450612 529194719 287622428 350370653 2490001
267842805 909540874 518481012 265798837 15815265 20879824
142543426 589509572 795333485 574202609 686307559
5 5 368241593
3 4 501344156
3 2 881313477
5 3 877155507
3 3 638857659
3 5 60427320
3 1 888140066
1 1 820913164
3 2 656494106
5 2 48265697...

output:

1792008237

result:

ok 1 number(s): "1792008237"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

6 1000
939223353 592232256 204123592 697949032 283207645
247227259 860831362 710972139 170824074 510978702 280845746
896873779 377774668 7308887 326686740 179453061
2 3 997446049
2 3 519323074
4 1 939589279
2 5 98041599
4 4 869921378
3 3 558765317
1 2 483873583
5 1 33483163
3 3 270388480
4 4 5510784...

output:

2035324394

result:

ok 1 number(s): "2035324394"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

6 1000
959730384 933307890 88544023 434800479 519026844
598287106 88518137 220336188 475197957 997211224 13754116
615549399 359488030 322300660 426429747 456751804
2 1 37534981
2 1 826968454
4 5 736905082
2 2 392058437
3 2 148710959
5 3 340405411
4 3 756316407
1 1 989545410
1 4 953888522
1 2 4208087...

output:

2778806746

result:

ok 1 number(s): "2778806746"

Test #5:

score: 0
Accepted
time: 1ms
memory: 3840kb

input:

6 1000
828474485 450284805 615710614 642827608 358927789
340890875 324511822 431939488 283505035 960286257 744621984
19345807 677774542 254789794 431703631 752285873
4 1 619213429
4 2 475954933
2 1 372220764
4 3 365954206
5 2 66701266
5 5 715874448
2 1 385795225
2 4 215024198
2 3 335608279
4 5 81229...

output:

2476790522

result:

ok 1 number(s): "2476790522"

Test #6:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

6 1000
773101001 64230554 596335108 570954044 371802052
672297875 609818176 210924742 474129815 637532288 845662045
381562818 836547701 790875625 459034073 816120888
3 4 171273656
2 2 669511947
1 5 99209262
4 1 393105839
4 2 161297430
3 2 175654558
4 4 895979780
2 1 380318119
2 3 438246899
2 2 61661...

output:

3222084804

result:

ok 1 number(s): "3222084804"

Test #7:

score: -100
Wrong Answer
time: 1ms
memory: 3712kb

input:

6 1000
786204681 325567741 53406367 432402436 442330564
1353889 4683275 528413577 555907196 568518211 61420817
117239404 703766279 710007531 852547435 543311026
1 1 830934334
2 3 981865567
3 2 439871419
3 2 377106611
1 1 849647504
2 4 590590318
5 5 333563280
3 4 908162812
1 3 384002897
4 4 701562502...

output:

1433721218

result:

wrong answer 1st numbers differ - expected: '1438404493', found: '1433721218'