Submission #418813

# Submission time Handle Problem Language Result Execution time Memory
418813 2021-06-05T23:18:18 Z Chaska Hop (COCI21_hop) C++11
0 / 110
1 ms 460 KB
#include <bits/stdc++.h>
using namespace std;
const int N =1005;
int n,a[N],dp[N][4],col[N][N];
int main()
{
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	cin >> n;
	for (int i=0;i<n;i++) 
		cin >> a[i];
	for (int i=n-2;i>=0;i--) {
		for (int j=i+1;j<n;j++) {
			if (a[j]%a[i] == 0) {
				int x,y,z;
				x = dp[j][1]+1;
				y = dp[j][2]+1;
				z = dp[j][3]+1;
				if (x<=3) {
					col[i][j] =1;
					dp[i][1] = max(dp[i][1],x);
				} else {
					if (y<=3) {
						col[i][j] = 2;
						dp[i][2] = max(dp[i][2],y);
					} else {
						col[i][j] = 3;
						dp[i][3] = max(dp[i][3],z);
					}
				}
			} else {
				col[i][j] = 1;
			}
		}
	}
	for (int i=1;i<n;i++) {
		for (int j=0;j<i;j++) {
			cout << col[j][i] << " ";
		}
		cout << "\n";
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Runtime error 1 ms 460 KB Execution killed with signal 8
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Runtime error 1 ms 460 KB Execution killed with signal 8
3 Halted 0 ms 0 KB -