No it should work in either case, because 1 - based humne first parameter ko kiya tha.
This is the code for zero based indexing though.
void solve() {
int n; cin >> n;
int a[n][3], dp[n][3] = {0};
for (int i = 0; i < n; i++) cin >> a[i][0] >> a[i][1] >> a[i][2], dp[i][0] = a[i][0], dp[i][1] = a[i][1], dp[i][2] = a[i][2];
for (int i = 1; i < n; i++) {
dp[i][0] += max(dp[i - 1][1], dp[i - 1][2]);
dp[i][1] += max(dp[i - 1][0], dp[i - 1][2]);
dp[i][2] += max(dp[i - 1][1], dp[i - 1][0]);
}
dp[n - 1][0] = max(dp[n - 1][0], dp[n - 1][1]);
dp[n - 1][0] = max(dp[n - 1][0], dp[n - 1][2]);
cout << dp[n - 1][0] << endl;
}