Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int x[101],a[101][101],n;
- void citire(int &n, int a[101][101])
- {
- int m,i,j,x,y;
- cin>>n;
- for(i=1;i<=n;i++)
- for(j=1;j<=n;j++)
- a[i][j]=0;
- cin>>m;
- for(i=1;i<=m;i++)
- {
- cin>>x>>y;
- a[x][y]=1;
- }
- }
- void tipar(int k)
- {
- int i;
- for(i=1;i<=k;i++)
- {
- if(x[i]==1)
- cout<<'R';
- else
- if(x[i]==2)
- cout<<'A';
- else
- cout<<'V';
- }
- }
- int cont(int k)
- {
- int i,j;
- for(i=1;i<k;i++)
- for(j=i+1;j<=k;j++)
- if(a[i][j]==1 || a[j][i]==1)
- {
- if(x[i]==x[j])
- return 0;
- }
- return 1;
- }
- void bkt()
- {
- int k=1;
- x[k]=0;
- while(k)
- {
- if(x[k]<3)
- {
- x[k]=x[k]+1;
- if(cont(k)==1)
- {
- if(k==n)
- {
- tipar(k);
- break;
- }
- else
- {
- k++;
- x[k]=0;
- }
- }
- }
- else
- k--;
- }
- }
- int main()
- {
- citire(n,a);
- bkt();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement