QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#250628#6389. TopicalWorld_Creater0 0ms0kbC++141.2kb2023-11-13 14:32:292023-11-13 14:32:29

Judging History

你现在查看的是最新测评结果

  • [2023-11-13 14:32:29]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2023-11-13 14:32:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m,vis[1000005],ans;
vector<int> a[1000005],b[1000005],id[1000005];
int f[1000005],p[1000005];
stack<int> sta;
void add()
{
	for(int i=1;i<=m;i++)
	{
		while(p[i]<n&&f[i]>=a[id[i][p[i]+1]][i])
		{
			// cerr<<i<<" "<<p[i]<<"\n";
			p[i]++;
			vis[id[i][p[i]]]++;
			if(vis[id[i][p[i]]]==m) sta.emplace(id[i][p[i]]);
		}
	}
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	freopen("topic.in","r",stdin);
	freopen("topic.out","w",stdout);
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		id[i].emplace_back();
	}
	for(int i=1;i<=n;i++)
	{		
		a[i].emplace_back();
		for(int j=1;j<=m;j++)
		{
			int x;
			cin>>x;
			a[i].emplace_back(x);
			id[j].emplace_back(i);
		}
	}
	for(int i=1;i<=n;i++)
	{
		b[i].emplace_back();
		for(int j=1;j<=m;j++)
		{
			int x;
			cin>>x;
			b[i].emplace_back(x);
		}
	}
	for(int i=1;i<=m;i++)
	{
		sort(id[i].begin()+1,id[i].end(),[&](int x,int y){
			return a[x][i]<a[y][i];
		});
	}
	do{
		if(!sta.empty())
		{
			int x=sta.top();
			sta.pop();
			for(int j=1;j<=m;j++)
			{
				f[j]+=b[x][j];
			}
			ans++;
		}
		add();
	}while(!sta.empty());
	cout<<ans;
}

详细

Subtask #1:

score: 0
Dangerous Syscalls

Test #1:

score: 0
Dangerous Syscalls

input:

1 1
693647287
340782526

output:


result:


Subtask #2:

score: 0
Dangerous Syscalls

Test #8:

score: 0
Dangerous Syscalls

input:

100 1
893339036
896783899
690308537
201770764
262364362
105000893
770698921
744238454
470980016
935046317
642998516
100481910
392307650
116783134
196939768
372329082
346372520
43063564
245523488
389084350
130314590
412588681
987795927
681635353
304582580
472268968
700147283
743357606
792644412
99955...

output:


result:


Subtask #3:

score: 0
Dangerous Syscalls

Test #15:

score: 0
Dangerous Syscalls

input:

10000 1
568857328
651788426
751475430
102940442
763289419
468657944
770847628
780257867
16919385
575963868
281824241
291248174
140016533
313529232
302186452
32709864
787073783
1926820
239509174
220454071
34252400
390385721
675239026
245106357
489697460
28435096
825528061
159083009
16370561
223299279...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #1:

0%