Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int leftside[5][10]; //l[0][i]=coefficient of a_i, [1]=b_i, [2]=c_i,[3]=d_i,[4]=x_i
- int rightside[5][10];
- int l[5][10];
- int r[5][10];
- void convert(vector<int> &v,int A[][10]){
- for (int i=0;i<v.size()-1;i++){
- int x=v[i],y=v[i+1];
- if (x<y){
- A[4][y]++,A[4][x]--;
- A[3][x]++,A[0][y]++;
- }
- else{
- A[4][x]++,A[4][y]--;
- A[2][x]++,A[1][y]++;
- }
- }
- }
- void cancel(int A[][10],int B[][10]){
- for (int i=0;i<5;i++) for (int j=1;j<=5;j++) B[i][j]-=A[i][j];
- }
- void print(int A[][10]){
- for (int i=0;i<5;i++){
- for (int j=1;j<=5;j++) cout<<A[i][j]<<' '; cout<<endl;
- }
- }
- int main(){
- freopen("readable.txt","w",stdout);
- for (int s=1;s<=5;s++) for (int e=1;e<=5;e++) if(e!=s) {
- memset(leftside,0,sizeof leftside); memset(rightside,0,sizeof rightside);
- memset(l,0,sizeof l), memset(r,0,sizeof r);
- vector<int> v;
- for (int i=1;i<=5;i++) if ((i!=s)&&(i!=e)) v.push_back(i);
- int a=v[0],b=v[1],c=v[2];
- //KNOW X(s,a,b,e)<=X(s,b,a,e)
- vector<int> path={s,a,b,e};
- cout<<s<<" -> "<<e<<endl;
- convert(path,leftside);
- vector<int> rpath={s,b,a,e};
- convert(rpath,rightside);
- cancel(leftside,rightside);
- print(rightside);
- cout<<endl;
- for (int p=0;p<3;p++){
- memset(l,0,sizeof l);
- vector<int> opt;
- if (p==0) opt={s,a,b,c,e};
- if (p==1) opt={s,a,c,b,e};
- if (p==2) opt={s,c,a,b,e};
- convert(opt,l);
- for (int q=0;q<3;q++){
- memset(r,0,sizeof r);
- vector<int> oth;
- if (q==0) oth={s,b,a,c,e};
- if (q==1) oth={s,b,c,a,e};
- if (q==2) oth={s,c,b,a,e};
- convert(oth,r);
- cancel(l,r);
- bool good=true;
- for (int i=0;i<5;i++) for (int j=1;j<=5;j++) if (rightside[i][j]!=r[i][j]) good=false;
- bool allZero=true;
- for (int i=0;i<5;i++) for (int j=1;j<=5;j++) if (r[i][j]!=0) allZero=false;
- if ((good)||(allZero)){
- for (int x:opt) cout<<x<<" "; cout<<"vs ";
- for (int x:oth) cout<<x<<" "; cout<<endl;
- print(r); cout<<endl;
- }
- }
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment