QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#774765#9788. Shrecklessucup-team1004#WA 23ms51908kbC++201.7kb2024-11-23 13:49:142024-11-23 13:49:15

Judging History

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

  • [2024-11-23 13:49:15]
  • 评测
  • 测评结果:WA
  • 用时:23ms
  • 内存:51908kb
  • [2024-11-23 13:49:14]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=1e6+5,M=N*4+5,K=1000+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(28382);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
	Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	#ifdef LOCAL
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
	#else 
	#define gdb(...) void()
	#endif
}using namespace Debug;
int n,m;
vector<int> S[N];
multiset<int> f[N];
void Solve(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m+1;i++) S[i].clear(),f[i].clear();
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			int x;scanf("%d",&x);
			if(j&1) f[j].insert(x);
			else S[j].push_back(x);
		}
	}
	int cnt=0;
	for(int i=2;i<=m;i+=2){
		sort(all(S[i]));
		reverse(all(S[i]));
		for(int j:S[i]){
			auto it=f[i-1].UB(j);
			if(it==f[i-1].end()){
				it=f[i+1].begin();
				if(it!=f[i+1].end()&&*it<j) cnt++,f[i+1].erase(it);
			}else cnt++,f[i-1].erase(it);
		}
	}
	puts(cnt>=n?"YES":"NO");
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

详细

Test #1:

score: 100
Accepted
time: 6ms
memory: 51908kb

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: 4ms
memory: 51648kb

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
Wrong Answer
time: 23ms
memory: 50992kb

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:

NO
NO
YES
NO
NO
YES
YES
YES
NO
NO
NO
NO
YES
YES
YES
YES
NO
NO
YES
NO
NO
NO
YES
NO
YES
YES
YES
YES
NO
NO
NO
YES
NO
YES
NO
NO
YES
NO
YES
YES
NO
NO
YES
NO
YES
NO
NO
YES
YES
YES
NO
NO
NO
YES
NO
YES
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
NO
YES
YES
YES
NO
NO
YES
NO
NO
NO
NO
NO
YES
YES
YES
NO
NO
YES
YES
NO
NO
NO...

result:

wrong answer expected YES, found NO [2nd token]