85分,3个超时,求助
查看原帖
85分,3个超时,求助
821156
ycyz_qxm楼主2023/3/19 15:57

代码如下

#include<bits/stdc++.h>
using namespace std;
int n,m,q,t;
struct node{
	int opt,x,c;
};
node cnm[100005];
int main(){
	scanf("%d",&t);
	for(int w = 1;w<=t;w++){
		scanf("%d %d %d",&n,&m,&q);
		for(int i = 1;i<=q;i++){
			scanf("%d %d %d",&cnm[i].opt,&cnm[i].x,&cnm[i].c);
		}
		for(int x = 1;x<=n;x++){
			for(int y = 1;y<=m;y++){
				for(int i = q;i>=0;i--){
					if(i == 0){
						cout<<0<<" ";
					}
					else if(cnm[i].opt == 0 && cnm[i].x == x){
						cout<<cnm[i].c<<" ";
						break;
					}
					else if(cnm[i].opt == 1 && cnm[i].x == y){
						cout<<cnm[i].c<<" ";
						break;
					}
				}
			}
			cout<<endl;
		}
	}
}
2023/3/19 15:57
加载中...