Problem
Test instructions
There is a 1 to N of a full arrangement, tells you the number of the first and all n the number of the smaller compared to which, compared to their own 0, so there is a main diagonal of 0 matrix, the original sequence
Analysis
My idea is, to give us each row and by the size of a row, we know that the number of numbers is the first in the series. Because it is the whole arrangement of N, so the first few is a few.
After the order of sum, r[sum[i].id]=i; This sentence indicates that the number in the ID location is now the first large, so r is the required full alignment.
Code
#include <stdio.h> #include <algorithm> #define N 60using namespace Std;long long n,ans,a,r[n];struct x{ int v,id;} Sum[n];int cmp (x a,x b) { return A.V<B.V;} int main () { scanf ("%lld", &n); for (int i=1; i<=n; i++) { for (int j=1; j<=n; j + +) { scanf ("%lld", &a); sum[i].v+=a; } sum[i].id=i; } Sort (sum+1,sum+1+n,cmp); for (int i=1; i<=n; i++) r[sum[i].id]=i; for (int i=1; i<=n; i++) printf ("%lld", R[i]); return 0;}
"Codeforces 618B" Guess the permutation