#include <bits/stdc++.h>
using namespace std;
int main()
{
std::ios_base::sync_with_stdio(0); std::cin.tie(nullptr); std::cout.tie(nullptr);
int n, k, mini=1000001, poz;
vector <int> odp;
bool rosn=true, nrosn=true;
cin>>n>>k;
int t[n];
if(k>2)
{
for(int i=0; i<n; ++i)
{
cin>>t[i];
if(t[i]<=mini)
{
mini=t[i];
poz=i;
}
}
if(poz==0)
{
cout<<"NIE";
return 0;
}
cout<<"TAK"<<endl;
for(int i=1; i<k; ++i)
{
if(i==k-2 && i<poz)
{
odp.push_back(poz);
if(poz+1!=n)
{
odp.push_back(poz+1);
++i;
}
}
else odp.push_back(i);
}
sort(odp.begin(), odp.end());
for(int i=0; i<odp.size(); ++i)
cout<<odp[i]<<" ";
}
else
{
int maxi1=0, maxi2=0, mini1=1000001;
for(int i=0; i<n; ++i)
{
cin>>t[i];
if(t[i]>maxi1)
{
maxi1=t[i];
poz=i;
}
}
for(int i=n-1; i>poz; --i)
{
if(t[i]>maxi2)
maxi2=t[i];
}
for(int i=0; i<=poz; ++i)
{
mini1=min(mini1, t[i]);
}
if(mini1>=maxi2)
cout<<"TAK"<<endl<<poz;
else cout<<"NIE";
}
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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | #include <bits/stdc++.h> using namespace std; int main() { std::ios_base::sync_with_stdio(0); std::cin.tie(nullptr); std::cout.tie(nullptr); int n, k, mini=1000001, poz; vector <int> odp; bool rosn=true, nrosn=true; cin>>n>>k; int t[n]; if(k>2) { for(int i=0; i<n; ++i) { cin>>t[i]; if(t[i]<=mini) { mini=t[i]; poz=i; } } if(poz==0) { cout<<"NIE"; return 0; } cout<<"TAK"<<endl; for(int i=1; i<k; ++i) { if(i==k-2 && i<poz) { odp.push_back(poz); if(poz+1!=n) { odp.push_back(poz+1); ++i; } } else odp.push_back(i); } sort(odp.begin(), odp.end()); for(int i=0; i<odp.size(); ++i) cout<<odp[i]<<" "; } else { int maxi1=0, maxi2=0, mini1=1000001; for(int i=0; i<n; ++i) { cin>>t[i]; if(t[i]>maxi1) { maxi1=t[i]; poz=i; } } for(int i=n-1; i>poz; --i) { if(t[i]>maxi2) maxi2=t[i]; } for(int i=0; i<=poz; ++i) { mini1=min(mini1, t[i]); } if(mini1>=maxi2) cout<<"TAK"<<endl<<poz; else cout<<"NIE"; } return 0; } |
English