#109

by asd

Submitted 2 years 11 months ago
Mon May 10 19:51:13 CST 2021
Judger: judger1
Dataset Version: v6

7 ms / 8876 KB
Final 100
Problem: lss4.war
Language: GNU C++ 11


#1

5ms / 8832KB / Accepted
Input
1
366873838 
823342 
871186 

Output
YES
823342 
Answer
YES
823342 
Checker Information
Nice planning. I like it.

#2

5ms / 8808KB / Accepted
Input
1
786030139 
17634 
920219 

Output
YES
17634 
Answer
YES
17634 
Checker Information
Nice planning. I like it.

#3

5ms / 8876KB / Accepted
Input
2
238780019 821018601 
328592 1844178 
827920 951052 
778600 929986 

Output
YES
328592 951052 
0 893126 
Answer
YES
131514 934859 
197078 909319 
Checker Information
Nice planning. I like it.

#4

5ms / 8836KB / Accepted
Input
2
741695309 922335591 
592422 546146 
980710 192811 
611887 897306 

Output
YES
592422 192811 
0 353335 
Answer
YES
18705 122545 
573717 423601 
Checker Information
Nice planning. I like it.

#5

4ms / 8788KB / Accepted
Input
5
57089137 33171435 906630800 531690631 350841426 
1783153 1994800 1462521 3139405 2925589 
911969 898678 636993 916006 895941 
812391 391258 313099 708065 998335 
874014 981501 691981 954323 451544 
887119 980062 696306 643730 697944 
628318 681190 721613 664312 835572 

Output
YES
911969 898678 636993 916006 895941 
812391 391258 313099 708065 998335 
58793 704864 512429 954323 451544 
0 0 0 561011 579769 
0 0 0 0 0 
Answer
YES
437087 114429 163215 847799 838881 
561497 325228 293522 236906 692299 
171272 865879 183606 936154 71236 
549831 365466 590560 595690 688188 
63466 323798 231618 522856 634985 
Checker Information
Nice planning. I like it.

#6

4ms / 8724KB / Accepted
Input
10
916691400 352566759 528788232 818826423 65230315 121863335 474928316 356189430 389733577 253913268 
5142635 4159091 6321980 6046706 4617930 4760431 5242490 3962178 5867462 4900423 
963129 604155 997169 925822 722624 821915 938572 958162 623565 935518 
664443 794225 700816 650213 379900 951679 879027 830663 977863 971700 
651990 758575 663379 680014 842948 680787 955149 531418 918207 924076 
476499 760489 961153 957698 785909 996995 199577 989805 910675 757599 
956660 910902 871084 967432 793470 908598 610909 758327 951857 886426 
819543 808350 995074 875539 899057 907158 930823 829315 764074 948940 
933417 974243 808013 942722 894714 986089 948073 989713 667730 942587 
208788 906328 957071 802323 508495 691689 900802 948899 795098 602416 
916923 138721 982314 837034 754920 534550 743007 893128 898501 179657 
854586 536731 669876 753959 990581 419329 133021 203049 977426 955881 

Output
YES
963129 604155 997169 925822 722624 821915 938572 958162 623565 935518 
664443 794225 700816 650213 379900 951679 879027 830663 977863 971700 
651990 758575 663379 680014 842948 680787 955149 531418 918207 924076 
476499 760489 961153 957698 785909 996995 199577 989805 910675 757599 
956660 910902 871084 967432 793470 908598 610909 652130 951857 886426 
819543 330745 995074 875539 899057 400457 930823 0 764074 425104 
610371 0 808013 942722 194022 0 728433 0 667730 0 
0 0 325292 47266 0 0 0 0 53491 0 
0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 
Answer
YES
901704 359105 959014 854881 87141 569997 453364 8144 523754 800422 
503999 244462 679273 158732 231663 923765 286586 591131 934532 840300 
220982 744870 185172 241049 413990 644158 596591 504189 826079 776751 
371434 705919 872474 947121 703282 860659 46482 640309 48181 5125 
397162 115133 723598 944914 681025 2843 485636 20483 776878 260025 
380097 338493 28221 700030 404366 743819 926584 599969 611486 12764 
705205 680907 545420 869949 589781 207040 876960 466179 420065 748155 
71889 706982 880620 627251 504476 366680 832975 846323 578061 444019 
814068 43099 895063 595748 169310 216522 689474 120435 176923 75807 
776095 220121 553125 107031 832896 224948 47838 165016 971503 937055 
Checker Information
Nice planning. I like it.

#7

3ms / 8732KB / Accepted
Input
10
3239312 2316901 936290 813764 389105 5637805 470482 1023638 2456729 543101 
5766694 5865294 3532593 5775469 5093925 5497789 4023563 3510287 3569974 7032436 
854255 958939 793925 817594 754095 951940 627269 935113 978258 959843 
776206 980040 703642 995722 920732 402204 765763 660301 661506 572581 
898299 984086 837793 760879 919355 991937 983624 736903 812056 853788 
856167 886831 588030 333279 611785 902359 997607 931012 681749 983155 
346618 671814 638650 612409 910273 690927 939372 646232 291354 894658 
984866 945941 992882 918503 424905 883493 553238 924541 940530 726261 
791442 638460 956582 830329 962236 773391 885280 858540 821379 869371 
959301 649065 484941 660432 464739 821700 891151 350102 597970 835537 
934537 963129 604155 997169 925822 722624 821915 938572 958162 623565 
935518 664443 794225 700816 650213 379900 951679 879027 830663 977863 

Output
NO
Answer
NO
Checker Information
No I guess?

#8

4ms / 8836KB / Accepted
Input
20
815353149 823320545 579283346 685912466 844019134 645055242 617838607 729574578 735045061 725410600 582406116 783007115 661760601 946219231 576677798 779623621 874631020 247174034 783358154 602190509 
8869998 10512422 9915330 8734151 8429075 9730695 8723304 11095684 10160071 11115169 9218311 7226830 9005102 11199632 9234681 7554640 10956721 9863860 9593491 9671907 
401764 994835 189591 881844 726688 173102 706544 893179 567986 899243 945000 987898 645235 683425 930684 998865 998807 314582 922621 672720 
708411 465591 903983 215863 971485 990231 283467 485315 379565 787454 818651 679887 458385 529132 901237 713737 454997 589005 979464 977947 
659750 707623 764062 997342 984591 929384 956519 444679 965412 590661 928964 428309 377600 700495 963108 845451 652301 585690 270719 907496 
592378 687953 269447 921023 773095 581235 719050 396240 947239 897205 753157 835157 965549 979911 542603 359252 847596 919977 736218 82087 
903098 835357 559571 720955 957181 981854 976338 388627 965469 898845 851156 661261<...>
Output
YES
401764 994835 189591 881844 726688 173102 706544 893179 567986 899243 945000 987898 645235 683425 930684 998865 998807 314582 922621 672720 
708411 465591 903983 215863 971485 990231 283467 485315 379565 787454 818651 679887 458385 529132 901237 713737 454997 589005 979464 977947 
659750 707623 764062 997342 984591 929384 956519 444679 965412 590661 928964 428309 377600 700495 963108 845451 652301 585690 270719 907496 
592378 687953 269447 921023 773095 581235 719050 396240 947239 897205 753157 835157 965549 979911 542603 359252 847596 919977 736218 82087 
903098 835357 559571 720955 957181 981854 976338 388627 965469 898845 851156 661261 978427 648439 924631 559207 919561 546435 851104 976253 
536354 667677 935928 663523 939130 623288 903264 399022 922558 977850 338038 898980 968365 860093 533864 759029 407952 987993 889153 943830 
892320 957272 438379 852149 986422 739917 899385 997486 502644 995992 683247 451581 291549 624229 238569 294568 985139 785561 960322 502118 
797511 777790 304325 818589 933246<...>
Answer
YES
391155 961589 113392 853107 522856 126400 679105 201545 521000 400660 112054 554609 416980 573881 488873 605141 960549 216549 873868 58951 
381031 438513 721127 200751 10174 947337 66020 469105 352841 518521 632080 636968 43007 269654 686564 706960 185575 280982 888514 699225 
388318 677652 242254 358659 901145 910278 730310 176731 700479 232190 729487 13511 242773 220222 913492 262717 490659 426353 31549 870515 
530320 15119 165155 662817 128689 1545 588629 270653 609494 47432 354042 619198 789293 784749 407546 280342 620537 638850 489959 12087 
368327 169316 544626 156321 51213 182476 13234 23983 912958 852025 671512 603425 906047 460167 857937 543754 706341 20707 538545 942454 
323205 154297 112997 298679 828746 585134 301302 264510 558176 846121 227625 164162 31991 783355 94452 660786 320457 966531 674399 890094 
428983 945123 96184 195954 356901 348516 551712 853080 182435 962993 117078 124064 35153 236809 26460 160353 972571 674252 946233 337975 
59418 638870 114547 6300 792906 154300 194738<...>
Checker Information
Nice planning. I like it.

#9

3ms / 8724KB / Accepted
Input
20
7816279 66625 8330139 2572858 6631488 9190000 5854853 3711790 3995757 3534540 6714325 3919047 6592912 642607 8803177 3576984 2184563 7152139 2198238 10263391 
9945858 9770585 10848803 10298219 8283249 9631376 9855860 9321158 10142760 10434052 9451642 9764209 9931258 6769904 10138709 7324730 8137390 10735200 7083632 10400567 
921743 957510 684915 994354 905080 580707 815631 838260 933607 493193 577795 669761 84615 609500 907755 750556 684593 746568 700982 871996 
669695 366326 484833 906239 827257 516365 764519 803754 629730 417457 941652 935107 837829 696396 997542 387600 785160 550029 510158 885510 
270010 799018 860562 573832 420077 818109 728579 792508 953100 742875 300016 764306 994778 653226 962982 913374 518750 869142 520419 401601 
839211 857779 897785 391513 646428 992898 199774 444639 930143 905107 642756 870876 122818 913781 780091 548266 735085 995550 993675 925322 
995475 935705 809767 516870 763582 751172 726372 279626 619959 949169 393129 498743 307829 549978 863811 400123 670632 98403<...>
Output
NO
Answer
NO
Checker Information
No I guess?

#10

7ms / 8796KB / Accepted
Input
50
819142155 96351798 326152207 210549418 849866136 452210174 251079325 586819216 797691946 792566398 249839360 263099510 46173314 91813373 206329790 78873879 448431852 945262508 262084333 882504865 188103123 213177582 345767537 602567230 930841378 281177285 796429788 350834324 799459967 440136066 477428647 230189789 990500240 161985141 654136324 799780937 767042972 259798910 830983680 581059973 707583575 40702651 520840678 286759149 172787864 559683789 595327727 172295517 144083312 628291224 
25490137 24849023 25968046 27310513 24371724 24600753 24076471 26029842 24757594 30262336 30098348 23762346 25152951 24019243 23939645 20746161 23188099 23481258 22491297 22556231 25851106 21766464 26715633 28410698 27474885 23916658 26346143 25945592 27324918 23590646 28730330 22531643 24184036 21411407 25168538 23498558 23674863 24547290 24635275 27355640 24901206 23034949 26887508 24652377 27897558 26174236 25251389 24931058 23031034 25546787 
681417 748567 985895 493516 810732 964057 963208 916552 767347 981678 9<...>
Output
YES
681417 748567 985895 493516 810732 964057 963208 916552 767347 981678 935406 380607 851747 966770 716420 616227 482364 997789 672074 803771 855098 758957 995557 997962 671875 530010 409631 995438 778408 953312 651071 437869 896777 298224 921487 994419 632425 960634 993575 644003 909721 677810 939595 871327 855637 898927 863893 816230 971805 930301 
856079 795332 994334 785828 397363 142889 667978 973610 821990 671210 727166 690372 595946 57403 941634 642236 246089 998884 995267 914295 789388 805384 870937 803563 717391 599865 997305 597418 522626 958830 745138 888846 277948 269220 786919 981180 359365 940084 659374 670888 874218 314312 802641 983004 999680 833451 912788 466692 912649 425766 
978823 607911 952020 977249 912033 363058 930708 761031 999673 901452 783828 859933 961690 691949 432834 930656 210932 928085 736768 965964 912839 401455 60955 425745 629051 295900 317794 981745 863298 181881 787967 958483 710288 867201 800426 999996 909819 587774 477245 720119 942245 424089 856056 586987 929394 95246<...>
Answer
YES
674741 445886 5444 178895 141612 907596 832321 362109 515340 938160 905361 340599 850314 730418 707363 398624 420423 911008 589334 522034 104267 411538 984164 975433 473409 477028 351570 895115 303668 908145 268862 79000 706568 77133 667947 942196 503367 92256 930918 462097 660487 250948 787695 795263 628424 740309 52158 599949 810136 530619 
677621 737908 873229 735705 344505 120705 500703 952112 502123 613183 722451 657706 154467 5518 856420 333370 115372 144525 992938 879964 609712 668512 221442 194551 521939 593410 995832 120990 384672 851032 658187 202990 238740 5342 681371 909198 297913 404298 587883 360865 672345 295354 63827 889221 835041 304422 238681 135646 776637 337781 
802929 195262 792220 513293 733775 257429 297924 702196 755644 870748 739270 426529 774865 387538 256031 244633 8303 840097 597958 902096 654585 303200 40204 44742 558371 130129 44888 968961 529421 118679 701070 718315 657857 680581 23829 998510 720136 151558 314049 100263 890953 360231 644024 386552 861778 844065 732189 183<...>
Checker Information
Nice planning. I like it.
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)

bool debug=true;

/*    *************************************
	  * Written in New Computer           *
	  * The following code belongs to     *
	  * XiaoGeNintendo of HellHoleStudios *
	  *************************************
*/
template<typename T1,typename T2>ostream& operator<<(ostream& os,pair<T1,T2> ptt){
	os<<ptt.first<<","<<ptt.second;
	return os;
}
template<typename T>ostream& operator<<(ostream& os,vector<T> vt){
	os<<"{";
	for(int i=0;i<vt.size();i++){
		os<<vt[i]<<" ";
	}
	os<<"}";
	return os;
}

/*
	Using Dinic Algorithm to get Maxflow problem
	By XGN from HHS
	Usage: 
	Dinic::addEdge(<start>,<to>,<val>)
	...
	Dinic::getMaxflow(<start>,<sink>)
*/
namespace Dinic{
	const int maxn=100005;
	const int INF=1e9+7;
	
	struct edge{
		int to,val,rev;
		edge(int a,int b,int c){
			to=a;
			val=b;
			rev=c;
		}
	};
	
	vector<edge> nei[maxn];
	int iter[maxn]; //当前弧
	int lv[maxn]; //分层
	
	void addEdge(int from,int to,int val){
		nei[from].push_back(edge(to,val,nei[to].size()));
		nei[to].push_back(edge(from,0,nei[from].size()-1));
	} 
	
	void bfs(int s){
		memset(lv,-1,sizeof(lv));
		queue<int> q;
		lv[s]=0;
		q.push(s);
		
		while(!q.empty()){
			int last=q.front();
			q.pop();
			
			for(int i=0;i<nei[last].size();i++){
				edge& e=nei[last][i];
				if(e.val>0 && lv[e.to]==-1){
					lv[e.to]=lv[last]+1;
					q.push(e.to);
				}
			}
		}
	}
	
	int dfs(int s,int t,int f){
		if(s==t){
			return f;
		}
		
		for(int& i=iter[s];i<nei[s].size();i++){ //当前弧优化!! 
			edge& e=nei[s][i];
			if(e.val>0 && lv[s]<lv[e.to]){
				int d=dfs(e.to,t,min(f,e.val));
				if(d>0){
					e.val-=d;
					nei[e.to][e.rev].val+=d;
					return d;
				}
			}
		}
		return 0;
	}
	
	int getMaxflow(int s,int t){
		int flow=0;
		while(true){
			bfs(s);
			if(lv[t]<0){
				break;
			}
			
			memset(iter,0,sizeof(iter));
			int f;
			while((f=dfs(s,t,INF))!=0){
				flow+=f;
			}
		}
		
		return flow;
	}
}; 

int n;
int r[55];
int c[55];
int a[55][55];
int ans[55][55];

int main(){
	qi;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>r[i];
	}
	
	ll sm=0;
	for(int i=0;i<n;i++){
		cin>>c[i];
		sm+=c[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>a[i][j];
		}
	}
	
	int S=2*n;
	int T=2*n+1;
	for(int i=0;i<n;i++){
		Dinic::addEdge(S,i,r[i]);
	}
	for(int i=0;i<n;i++){
		Dinic::addEdge(i+n,T,c[i]);
	}
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			Dinic::addEdge(i,j+n,a[i][j]);
		}
	}
	
	int x=Dinic::getMaxflow(S,T);
	if(x!=sm){
		cout<<"NO";
		return 0;
	}
	for(int i=0;i<n;i++){
		for(Dinic::edge& e:Dinic::nei[i]){
			if(e.to>=n && e.to<2*n){
				ans[i][e.to-n]=a[i][e.to-n]-e.val;
			}
		}
	}
	
	cout<<"YES"<<endl;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cout<<ans[i][j]<<" ";
		}
		cout<<endl;
	}
	
	return 0;
}