QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#773438#9788. Shrecklessucup-team3555#RE 1ms3628kbC++20867b2024-11-23 08:48:572024-11-23 08:49:02

Judging History

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

  • [2024-11-23 08:49:02]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3628kb
  • [2024-11-23 08:48:57]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N=2e5+3;
int n,m;
vector<int>a[N];
void Solve()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)a[i].resize(m+1);
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)cin>>a[i][j];
	vector<int>now(n+1,0),nb(n+1,0);nb[0]=1;
	for(int i=1;i<=n;i++)now[i]=a[i][1];
	sort(now.begin(),now.end());
	for(int i=1;i<=n;i++)a[i][1]=now[i];
	for(int t=2;t<=m;t++)
	{
		for(int i=1;i<=n;i++)now[i]=a[i][t];
		sort(now.begin(),now.end());vector<int>cur(m+1,0);
		for(int i=1,hd=1,tl=n;i<=n;i++)
		{
			if(nb[i]||a[i][t-1]<=now[hd])cur[i]=now[tl--];
			else nb[i]=1,cur[i]=now[hd++];
		}
		for(int i=1;i<=n;i++)a[i][t]=cur[i];
	}
	puts(!count(nb.begin(),nb.end(),0)?"YES":"NO");
}
int main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int T;cin>>T;
	while(T--)Solve();
	return 0; 
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3628kb

input:

3
2 2
69 69
2024 42
3 3
1 1 1
1 1 1
2 2 2
3 4
1 1 1 1
1 1 1 1
2 2 2 2

output:

YES
NO
YES

result:

ok 3 token(s): yes count is 2, no count is 1

Test #2:

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

input:

3
2 2
69 69
2024 42
3 3
1 1 1
1 1 1
2 2 2
3 4
1 1 1 1
1 1 1 1
2 2 2 2

output:

YES
NO
YES

result:

ok 3 token(s): yes count is 2, no count is 1

Test #3:

score: -100
Runtime Error

input:

20000
6 2
12 4
8 24
2 10
1 22
3 15
18 20
3 3
3 8 18
2 17 15
13 4 6
3 3
7 17 15
8 6 3
18 13 9
3 3
2 3 14
1 7 17
4 6 13
3 3
6 10 14
3 9 13
1 7 15
2 4
1 3 16 14
6 10 4 2
3 3
3 2 17
7 11 13
16 5 18
2 3
2 3 6
4 1 5
2 4
4 6 13 14
2 11 12 16
3 3
2 8 12
4 9 17
5 7 18
3 2
5 10
8 9
1 6
2 2
2 4
1 3
2 3
12 6 1
...

output:


result: