Submission #328047

# Submission time Handle Problem Language Result Execution time Memory
328047 2020-11-15T09:33:17 Z MonkeyKing JOIRIS (JOI16_joiris) C++14
Compilation error
0 ms 0 KB
#include <self/utility>
#include <self/debug>
using namespace std;
int n,k;
int a[55];
int s[55];
int g[55][2505];
vector <pii> res;

inline void error()
{
	cout<<-1<<endl;
	exit(0);
}

inline void putV(int col)
{
	res.push_back(mp(1,col+1));
	// cout<<1<<' '<<col+1<<endl;
}

inline void putH(int row)
{
	res.push_back(mp(2,row+1));
	// cout<<2<<' '<<row+1<<endl;
}

int main()
{
	freopen("input.txt","r",stdin);
	freopen("1.out","w",stdout);
	// freopen("input.txt","r",stdin);
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
	{
		scanf("%d",a+i);
		s[i%k]+=a[i];
	}
	for(int i=0;i<k;i++)
	{
		s[i]%=k;
	}
	for(int i=0;i<n%k;i++)
	{
		if(s[i]!=s[0]) error();
	}
	for(int i=n%k+1;i<k;i++)
	{
		if(s[i]!=s[n%k]) error();
	}
	for(int i=1;i<n;i++)
	{
		while(a[i]<a[i-1])
		{
			a[i]+=k;
			putV(i);
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<a[i];j++)
		{
			g[i][j]=true;
		}
	}
	memset(s,0,sizeof(s));
	for(int h=0;h<a[n-1];h++)
	{
		for(int i=n-1;i>=k-1;i--)
		{
			if(g[i][h]) continue;
			putH(i-k+1);
			for(int j=i-k+1;j<=i;j++)
			{
				s[j]++;
				g[j][h]=true;
			}
		}
	}
	for(int i=0;i<k;i++)
	{
		for(int j=0;j<k;j++)
		{
			putV(i);
		}
		// cout<<a[i]<<' '<<s[i]<<' '<<k*k<<' '<<a[n-1]<<endl;
		a[i]=a[i]+s[i]+k*k-a[n-1];
	}
	for(int i=0;i<k;i++)
	{
		assert(a[i]<=k*k);
		while(a[i]<k*k)
		{
			a[i]+=k;
			putV(i);
		}
	}
	for(int i=k;i<n;i++)
	{
		for(int j=0;j<k;j++)
		{
			putV(i);
		}
	}
	for(int i=0;i<k;i++)
	{
		a[i]-=k*k;
	}
	if(n%k==0) return 0;
	int t=a[n%k-1];
	while(t--)
	{
		for(int i=n%k;i<n;i+=k)
		{
			putH(i);
		}
	}
	cout<<res.size()<<endl;
	for(auto &p:res)
	{
		cout<<p.first<<' '<<p.second<<endl;
	}
	return 0;
}

Compilation message

joiris.cpp:1:10: fatal error: self/utility: No such file or directory
    1 | #include <self/utility>
      |          ^~~~~~~~~~~~~~
compilation terminated.