#include <iostream> #include <cstdint> #include <vector> #include <utility> #include <algorithm> #include <bitset> #include <limits> using namespace std; struct bla{ int position; int colour; int operation; // +1 add, -1 remove bool operator < (const bla &rhs) const { return (position<rhs.position); } }; int main(){ std::ios::sync_with_stdio(false); cin.tie(0); int n; cin >>n; vector <int> tab; int m=n; tab.push_back(0); while (m-->0){ int t; cin>>t; tab.push_back(t); } bool OK = true; for (int i=0; i<n && OK; i++) for(int j=i+1; j<=n && OK; j++) { OK = (tab[j]-tab[i] <= tab[j-i]) && OK; } if (OK){ cout<<"TAK"<<endl; cout<<n<<endl; for (int i=1; i<=n; i++){ cout<<tab[i]-tab[i-1]<<" "; } cout<<endl; }else{ cout<<"NIE"<<endl; } return 0; }
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 | #include <iostream> #include <cstdint> #include <vector> #include <utility> #include <algorithm> #include <bitset> #include <limits> using namespace std; struct bla{ int position; int colour; int operation; // +1 add, -1 remove bool operator < (const bla &rhs) const { return (position<rhs.position); } }; int main(){ std::ios::sync_with_stdio(false); cin.tie(0); int n; cin >>n; vector <int> tab; int m=n; tab.push_back(0); while (m-->0){ int t; cin>>t; tab.push_back(t); } bool OK = true; for (int i=0; i<n && OK; i++) for(int j=i+1; j<=n && OK; j++) { OK = (tab[j]-tab[i] <= tab[j-i]) && OK; } if (OK){ cout<<"TAK"<<endl; cout<<n<<endl; for (int i=1; i<=n; i++){ cout<<tab[i]-tab[i-1]<<" "; } cout<<endl; }else{ cout<<"NIE"<<endl; } return 0; } |