This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int TAILLE_MAX=100*1000+5;
int nbPort,ligPrem,colPrem;
int mat[2][TAILLE_MAX];
void echange(int colDeb,int colFin) {
swap(mat[0][colDeb],mat[0][colFin]);
swap(mat[1][colDeb],mat[1][colFin]);
}
void posit(int col) {
if (mat[0][col]<0) {
mat[0][col]*=-1;
mat[1][col]*=-1;
}
}
void modif(int colModif,int colAj,int coeff) {
mat[0][colModif]+=coeff*mat[0][colAj];
mat[1][colModif]+=coeff*mat[1][colAj];
}
void calc(int colDeb,int colFin) {
posit(colDeb);
posit(colFin);
if (mat[0][colDeb]<mat[0][colFin]) {
echange(colDeb,colFin);
}
while (mat[0][colFin]>0) {
modif(colDeb,colFin,mat[0][colDeb]/mat[0][colFin]);
echange(colDeb,colFin);
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>nbPort;
cin>>colPrem>>ligPrem;
if (nbPort<=2) {
cout<<-1<<endl;
return 0;
}
int colNouv,ligNouv;
for (int i=0;i<nbPort-1;i++) {
cin>>colNouv>>ligNouv;
mat[0][i]=ligNouv-ligPrem;
mat[1][i]=colNouv-colPrem;
}
calc(0,1);
int rep=mat[0][0]*mat[1][1]-mat[0][1]*mat[1][0];
if (rep==0) {
cout<<-1<<endl;
}
else {
cout<<abs(rep)<<endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |