답안 #970287

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
970287 2024-04-26T10:21:49 Z parlimoos Naan (JOI19_naan) C++14
0 / 100
2 ms 348 KB
//Be Name KHODA
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
#define pb push_back
#define pp pop_back
#define lb lower_bound
#define ub upper_bound
#define arr(x) array<ll , x>
#define endl '\n'

ll n , l;
ll mat[2000][2000];
vector<arr(2)> pts[2000] , o;
vector<int> ord;
bool use[2000];

bool cmpKsr(arr(2) &a , arr(2) &b){
    return ((a[0] * b[1]) < (a[1] * b[0]));
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    freopen("in.txt" , "r" , stdin);

    cin >> n >> l;
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < l ; j++){
            cin >> mat[i][j];
            mat[i][j] *= n;
        }
    }
    for(int i = 0 ; i < n ; i++){
        ll sm = 0 , tn = 0;
        for(int j = 0 ; j < l ; j++) sm += mat[i][j];
        sm /= n , tn = sm; 
        for(int j = 0 ; j < l ; j++){
            while(mat[i][j] >= tn){
                arr(2) d = {tn , mat[i][j]};
                ll g = __gcd(d[0] , d[1]);
                d[0] /= g , d[1] /= g;
                d[0] += (1ll * j) * d[1];
                pts[i].pb(d) , tn += sm;
            }
            tn -= mat[i][j];
        }
    }
    for(int i = 0 ; i < n ; i++){
        for(int j = 1 ; j < n ; j++) if(cmpKsr(pts[i][j] , pts[i][j - 1])){
            cout << pts[i][j][0] << " " << pts[i][j][1] << ":\n";
            cout << pts[i][j - 1][0] << " " << pts[i][j - 1][1] << "::\n";
            exit(0);
        }
    }

    for(int i = 0 ; i < n ; i++){
        arr(2) pt = {-1 , -1};
        int inx = -1;
        for(int j = 0 ; j < n ; j++){
            if(use[j]) continue;
            if(pt[0] == -1 or cmpKsr(pts[j][i] , pt)) pt = pts[j][i] , inx = j;
        }
        o.pb(pt) , use[inx] = 1 , ord.pb(inx);
    }
    for(int i = 1 ; i < n - 1 ; i++){
        if(!cmpKsr(o[i - 1] , o[i])){
            cout << o[i][0] << " " << o[i][1] << ":\n";
            cout << o[i - 1][0] << " " << o[i - 1][1] << "::\n";
            exit(0);
        }
    }
    for(int i = 1 ; i < n ; i++) cout << o[i - 1][0] << " " << o[i - 1][1] << endl;
    for(int i = 0 ; i < n ; i++) cout << ord[i] + 1 << " ";
}

Compilation message

naan.cpp: In function 'int main()':
naan.cpp:29:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     freopen("in.txt" , "r" , stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 344 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 344 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -