Advertisement
Guest User

gildia

a guest
Jan 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include <bitset>
  2. #include <iostream>
  3. using namespace std;
  4. int m,n,a,b,t[200001],v=0;
  5. bitset <200005> prawda;
  6. void funkcja(int x,int y)
  7. {
  8.     if(t[y]==1)
  9.     {
  10.         if(t[x]==2)
  11.             t[x]=0;
  12.              else
  13.             t[x]=2;
  14.     }
  15.     else if(t[y]==2)
  16.     {
  17.          if(t[x]==1)
  18.             t[x]=0;
  19.             else
  20.                 t[x]=1;
  21.     }
  22.         else
  23.     {
  24.     t[x]=2;}
  25. }
  26. int main() {
  27. cin>>n>>m;
  28. for(int i=0;m!=i;i++)
  29. {
  30.     cin>>a>>b;
  31.     if(t[a]==0)
  32.     funkcja(a,b);
  33.     if(t[b]==0)
  34.     funkcja(b,a);
  35.     prawda[a]=1;
  36.     prawda[b]=1;
  37. }
  38. for(int i=1;n>=i;i++)
  39. {
  40.     if(prawda[i]==0)
  41.     {
  42.         v=1;
  43.         cout<<"NIE";
  44.         break;
  45.     }
  46. }
  47. if(v==0)
  48. {
  49.     cout<<"TAK"<<endl;
  50.  
  51. for(int i=1;n>=i;i++)
  52.    {
  53.        if(t[i]==0)
  54.         cout<<"N\n";
  55.        else if(t[i]==1)
  56.         cout<<"K\n";
  57.        else
  58.         cout<<"S\n";
  59.    }
  60. }
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement