QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#340363#7398. Triangle TilingDaiRuiChen007Compile Error//C++172.0kb2024-02-28 21:46:362024-02-28 21:46:36

Judging History

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

  • [2024-02-28 21:46:36]
  • 评测
  • [2024-02-28 21:46:36]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int MAXN=5005;
struct ZkwSegt {
	static const int N=1<<13;
	int tr[N<<1];
	void psu(int p) {
		int t=max(tr[p<<1],tr[p<<1|1]);
		tr[p]+=t,tr[p<<1]-=t,tr[p<<1|1]-=t;
	}
	void init(int n) {
		memset(tr,0,sizeof(tr));
		for(int i=1;i<=n;++i) tr[i+N]=i-1;
		for(int i=N-1;i;--i) psu(i);
	}
	void add(int l,int r) {
		for(l+=N-1,r+=N+1;l^r^1;l>>=1,r>>=1) {
			if(~l&1) ++tr[l^1];
			if(r&1) ++tr[r^1];
			psu(l>>1),psu(r>>1);
		}
		while(l>1) psu(l>>=1);
	}
	int qry(int l,int r) {
		int sl=0,sr=0;
		for(l+=N,r+=N;(l^r)>1;l>>=1,r>>=1) {
			sl+=tr[l],sr+=tr[r];
			if(~l&1) sl=max(sl,tr[l^1]);
			if(r&1) sr=max(sr,tr[r^1]);
		}
		int s=max(sl+tr[l],sr+tr[r]);
		while(l>1) s+=tr[l>>=1];
		return s;
	}
}	T;
char s[MAXN][MAXN],t[MAXN][MAXN];
vector <int> g[MAXN],o[MAXN];
void init(int x) {
	T.init(x);
	for(int i=1;i<=x;++i) o[i].clear();
	for(int i=1;i<=x;++i) for(int j:g[i]) {
		o[j+x-i].push_back(j);
	}
}
void solve() {
	#define qt return puts("Impossible"),void()
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		scanf("%s",s[i]+1);
		for(int j=1;j<=i;++j) if(s[i][j]=='0') g[i].push_back(j),t[i][j]='-';
	}
	init(n);
	for(int i=1;i<=n;++i) {
		for(int j:o[i]) T.add(1,j);
		if(T.qry(1,i)>i) qt;
	}
	for(int i=n;i>1;--i) {
		if(g[i].empty()) qt;
		init(i-1);
		int lst=0,pos=0;
		for(int j=1;j<=i;++j) {
			for(int k:o[j]) T.add(1,k);
			if(s[i][j]=='0') {
				s[i-1][pos]='0',t[i-1][pos]='2',g[i-1].push_back(pos);
				for(int k=lst+1;k<=pos;++k) t[i][k]='1';
				for(int k=pos+1;k<j;++k) t[i][k]='3';
				T.add(1,pos),lst=pos=j;
			}
			if(j==i) break;
			if(T.qry(1,j)>j) qt;
			if(lst&&T.qry(1,lst)>=j) pos=j+1;
		}
		for(int j=lst+1;j<=i;++j) t[i][j]='1';
	}
	for(int i=1;i<=n;++i) printf("%s\n",t[i]+1);
	return 0;
}
signed main() {
	int T;
	scanf("%d",&T);
	while(T--) {
		solve();
		for(int i=1;i<=n;++i) {
			g[i].clear(),o[i].clear();
			for(int j=1;j<=i;++j) s[i][j]=t[i][j]=0;
		}
	}
	return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:77:16: error: return-statement with a value, in function returning ‘void’ [-fpermissive]
   77 |         return 0;
      |                ^
answer.code: In function ‘int main()’:
answer.code:84:32: error: ‘n’ was not declared in this scope
   84 |                 for(int i=1;i<=n;++i) {
      |                                ^
answer.code: In function ‘void solve()’:
answer.code:48:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   48 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
answer.code:50:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   50 |                 scanf("%s",s[i]+1);
      |                 ~~~~~^~~~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:81:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   81 |         scanf("%d",&T);
      |         ~~~~~^~~~~~~~~