TLE后三点,help
查看原帖
TLE后三点,help
755114
CD43楼主2022/8/18 16:52
#include <bits/stdc++.h>
using namespace std; 
long long n,m;
long long a[1000001];
int main(){
	std::ios::sync_with_stdio(false);//去同步优化
	cin.tie(0);//缓存优化 
	cout.tie(0);//缓存优化
	cin>>n;
	m=n;
	for(register int i(1);i<=n;++i)
	{
		cin>>a[i];
		a[i]++;
	}
	while(m)
	{
		int x=0;
		for(register int i(1);i<=n;++i)
		{
			for(;a[i]!=0&&a[i]!=x;i++){
				cout<<i<<" ";
				x=a[i];
				a[i]=0;
				m--;
			}
		}
		cout<<"\n";
	}
    return 0;
}
//for (register int i(1); i <= n; ++ i)循环加速
//register int 变量定义优化
//inline 函数优化 
//cout<<111<<"\n";

氧气无用

2022/8/18 16:52
加载中...