답안 #702471

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
702471 2023-02-24T07:25:32 Z alvingogo Naan (JOI19_naan) C++14
100 / 100
705 ms 181624 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define p_q priority_queue
#define int long long
using namespace std;

struct fac{
    int x,a,b;
    fac(){
        x=0;
        a=0;
        b=1;
    }
    fac(int c,int d,int e){
        x=c;
        if(d){
            int g=__gcd(d,e);
            a=d/g;
            b=e/g;
        }
        else{
            a=0;
            b=1;
        }
        if(a==b){
            x++;
            a=0;
        }
    }
    bool operator< (const fac& c) const{
        if(c.x!=x){
            return x<c.x;
        }
        return a*c.b<b*c.a;
    }
    void print(){
        cout << x*b+a << " " << b << "\n";
    }
};
signed main(){
    AquA;
    int n,l;
    cin >> n >> l;
    vector<vector<int> > v(n,vector<int>(l));
    vector<int> ave(n);
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            cin >> v[i][j];
            v[i][j]*=n;
            ave[i]+=v[i][j];
        }
        ave[i]/=n;
    }
    auto v2=v;
    vector<vector<fac> > dl(n);
    for(int i=0;i<n;i++){
        int nw=0;
        for(int j=0;j<l;j++){
            int y=ave[i]-nw;
            while(y<=v[i][j]){
                dl[i].push_back(fac(j,y,v[i][j]));
                y+=ave[i];
            }
            nw=(nw+v[i][j])%ave[i];
        }
        assert(dl[i].size()==n);
    }
    vector<int> vis(n);
    vector<int> z;
    for(int i=0;i<n;i++){
        int x=-1;
        for(int j=0;j<n;j++){
            if(!vis[j] && (x==-1 || dl[j][i]<dl[x][i])){
                x=j;
            }
        }
        if(i!=n-1){
            dl[x][i].print();
        }
        vis[x]=1;
        z.push_back(x);
    }
    
    for(auto h:z){
        cout << h+1 << " ";
    }
    cout << "\n";
    return 0;
}

Compilation message

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from naan.cpp:1:
naan.cpp: In function 'int main()':
naan.cpp:69:28: warning: comparison of integer expressions of different signedness: 'std::vector<fac>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   69 |         assert(dl[i].size()==n);
      |                ~~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 360 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 360 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 468 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 2 ms 468 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 2 ms 468 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 468 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 340 KB Output is correct
42 Correct 2 ms 468 KB Output is correct
43 Correct 60 ms 15744 KB Output is correct
44 Correct 354 ms 86728 KB Output is correct
45 Correct 161 ms 41852 KB Output is correct
46 Correct 19 ms 4800 KB Output is correct
47 Correct 242 ms 54176 KB Output is correct
48 Correct 447 ms 105804 KB Output is correct
49 Correct 109 ms 30192 KB Output is correct
50 Correct 606 ms 140832 KB Output is correct
51 Correct 225 ms 60736 KB Output is correct
52 Correct 516 ms 134392 KB Output is correct
53 Correct 455 ms 114128 KB Output is correct
54 Correct 1 ms 468 KB Output is correct
55 Correct 211 ms 54996 KB Output is correct
56 Correct 309 ms 83508 KB Output is correct
57 Correct 243 ms 69076 KB Output is correct
58 Correct 407 ms 110200 KB Output is correct
59 Correct 251 ms 71372 KB Output is correct
60 Correct 627 ms 162552 KB Output is correct
61 Correct 642 ms 162736 KB Output is correct
62 Correct 705 ms 178712 KB Output is correct
63 Correct 667 ms 181624 KB Output is correct
64 Correct 652 ms 181428 KB Output is correct
65 Correct 669 ms 168004 KB Output is correct
66 Correct 657 ms 168148 KB Output is correct
67 Correct 605 ms 168136 KB Output is correct
68 Correct 257 ms 82548 KB Output is correct
69 Correct 256 ms 82892 KB Output is correct
70 Correct 312 ms 99316 KB Output is correct
71 Correct 403 ms 125108 KB Output is correct