Submission #14259573


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














int N, K, A[201010], B[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> K;
	rep(i, 0, N) cin >> A[i];

	rep(k, 0, K) {
		rep(i, 0, N) B[i] = 0;
		rep(i, 0, N) {
			int L = max(0, i - A[i]);
			int R = min(N - 1, i + A[i]);

			B[L]++;
			B[R + 1]--;
		}
		rep(i, 1, N) B[i] += B[i - 1];

		bool same = true;
		rep(i, 0, N) {
			if (A[i] != B[i]) same = false;
			A[i] = B[i];
		}

		if (same) break;
	}

	rep(i, 0, N) {
		if(i) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}





Submission Info

Submission Time
Task C - Lamps
User hamayanhamayan
Language C++ (GCC 9.2.1)
Score 500
Code Size 1892 Byte
Status AC
Exec Time 73 ms
Memory 5248 KB

Judge Result

Set Name $Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 23
Set Name Test Cases
$Sample sample01.txt, sample02.txt
All sample01.txt, sample02.txt, in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, sample01.txt, sample02.txt
Case Name Status Exec Time Memory
in01.txt AC 38 ms 5076 KB
in02.txt AC 73 ms 5248 KB
in03.txt AC 68 ms 5080 KB
in04.txt AC 58 ms 5244 KB
in05.txt AC 57 ms 4860 KB
in06.txt AC 56 ms 5036 KB
in07.txt AC 56 ms 5004 KB
in08.txt AC 58 ms 5128 KB
in09.txt AC 37 ms 5204 KB
in10.txt AC 40 ms 5020 KB
in11.txt AC 36 ms 4904 KB
in12.txt AC 45 ms 5016 KB
in13.txt AC 58 ms 5016 KB
in14.txt AC 55 ms 5084 KB
in15.txt AC 34 ms 5112 KB
in16.txt AC 68 ms 5028 KB
in17.txt AC 63 ms 5032 KB
in18.txt AC 45 ms 4992 KB
in19.txt AC 45 ms 5084 KB
sample01.txt AC 5 ms 3620 KB
sample02.txt AC 2 ms 3500 KB