1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <bits/stdc++.h>

using namespace std;

int n;
vector<pair<int, int>> adj[310];
vector<int> waga(310, 1e9);
vector<int> tab(310, 1e9);

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    cin >> n;
    waga[0] = 0;
    tab[0] = 0;
    for (int i=1; i<=n; ++i) {
        int x;
        cin >> x;
        tab[i] = x;
        for (int j=0; j<=n-i; ++j) {
            adj[j].push_back({i+j, x});
        }
    }
    /*
    for (int i=0; i<=n; ++i){
        cout << i << ": ";
        for (auto u: adj[i]) {
            cout << "(" << u.first << ", " << u.second << ") ";
        } cout << endl;
    } */

    for (int i=0; i<n; ++i) {
        for (auto u: adj[i]) {
            waga[u.first] = min(waga[u.first], waga[i] + u.second);
        }
    }
/*
    for (int i=1; i<=n; ++i){
        cout << waga[i] << ' ';
    }
    cout << endl;
    for (int i=1; i<=n; ++i){
        cout << waga[i] - waga[i-1] << ' ';
    } cout << endl;
       */ 
    bool exist = true;
    for (int i=1; i<=n; ++i) {
        if (waga[i] != tab[i]) {
            exist = false;
        }
    }
    if (exist) {
        cout << "TAK\n";
        cout << n << endl;
        for (int i=1; i<=n; ++i)
            cout << tab[i] - tab[i-1] << ' ';
    } else cout << "NIE";

}