QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#87940#960. Output Limit ExceededCrysflyTL 40ms3516kbC++141.6kb2023-03-14 21:21:332023-03-14 21:21:34

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-14 21:21:34]
  • Judged
  • Verdict: TL
  • Time: 40ms
  • Memory: 3516kb
  • [2023-03-14 21:21:33]
  • Submitted

answer

#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define int long long
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	return f?-x:x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 6005
#define inf 0x3f3f3f3f

int n,res[maxn];
vi e[maxn];
int bel[maxn];
bool vis[maxn];
bool dfs(int u){
	if(vis[u])return 0; vis[u]=1;
	for(int v:e[u]){
		int w=bel[v];
		bel[u]=v,bel[v]=u;
		if(!w)return 1;
		bel[w]=0;
		if(dfs(w))return 1;
		bel[u]=0,bel[v]=w,bel[w]=v;
	}return 0;
}
void solve(int m)
{
	res[0]=1;
	For(i,1,m){
		e[i].pb(m+(n-n/i*i)+1);
		For(j,1,i-1) if((n-i+1)%j==0) e[j].pb(m+i);
		memset(vis,0,sizeof vis);
		For(j,1,i)
			if(!bel[j]){
				memset(vis,0,sizeof vis);
				dfs(j); 
			}
		bool ok=1;
		For(j,1,i)if(!bel[j]){ok=0;break;}
		res[i]=ok;
	}
}
void brute(){
	solve(n/2);
	cout<<2<<"\n"<<n+1<<' ';
	For(i,0,n)if(i<=n/2)cout<<res[i]<<' ';else cout<<res[n-i]<<" "; exit(0);
}
vi o;
void qwq(int n){
	Rep(i,60,0)
		if(n>>i&1){
			if(!i)o.pb(0);
			else o.pb(i+1);
		}
}
signed main()
{
	n=read();
	if(n<=6005)brute();
	solve(3000);
	cout<<61<<"\n";
	cout<<"2 0 0\n";
	For(i,3,60)cout<<2<<" "<<i-1<<" "<<i-1<<"\n";
	For(i,0,3000)o.pb(res[i]);
	qwq(n-2*3000-1);
	Rep(i,3000,0)o.pb(res[i]);
	cout<<o.size()<<" ";
	for(int x:o)cout<<x<<" ";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3460kb

input:

1

output:

2
2 1 1 

result:

ok OK 2 ones: 0 1

Test #2:

score: 0
Accepted
time: 2ms
memory: 3396kb

input:

0

output:

2
1 1 

result:

ok OK 1 ones: 0

Test #3:

score: 0
Accepted
time: 2ms
memory: 3424kb

input:

7

output:

2
8 1 1 1 0 0 1 1 1 

result:

ok OK 6 ones: 0 1 2 5 6 7

Test #4:

score: 0
Accepted
time: 40ms
memory: 3516kb

input:

1000

output:

2
1001 1 1 1 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok OK 18 ones: 0 1 2 3 4 5 6 7 9 991 993 994 995 996 997 998 999 1000

Test #5:

score: -100
Time Limit Exceeded

input:

1000000000000000000

output:


result: