답안 #524406

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
524406 2022-02-09T07:19:22 Z alirezasamimi100 Naan (JOI19_naan) C++17
100 / 100
421 ms 96756 KB
/*#pragma GCC optimize("Ofast,unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")*/
/*#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma")*/
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using pll=pair<ll,ll>;
using pii=pair<int,int>;
using point=complex<double>;
#define F first
#define S second
//#define X real()
//#define Y imag()
#define pb push_back
#define mp make_pair
#define lc v<<1
#define rc v<<1|1
#define fast_io ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define kill(x) cout << x << '\n';exit(0)
#define killshayan kill("done!")
#define killmashtali kill("Hello, World!")
const int N=2e3+10,LN=19,M=1e5+10,SQ=450,BS=737,inf=1e9,NSQ=N/SQ+1;
const ll INF=1e18;
const double pi=acos(-1);
const ld ep=1e-7;
const int MH=1000696969,MD=998244353,MOD=1000000007;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pii, null_type,greater<pii>, rb_tree_tag,tree_order_statistics_node_update>
ll pow(ll x, ll y, ll mod){
    ll ans=1;
    while (y != 0) {
        if (y & 1) ans = ans * x % mod;
        y >>= 1;
        x = x * x % mod;
    }
    return ans;
}
pll b[N][N];
ll n,m,a[N][N],p[N],q[N],s[N];
int main(){
    fast_io;
    cin >> n >> m;
    for(ll i=1; i<=n; i++){
        for(ll j=1; j<=m; j++){
            cin >> a[i][j];
            s[i]+=a[i][j];
        }
    }
    for(ll i=1; i<=n; i++){
        ll p=1,x=0;
        for(ll j=1; j<=n; j++){
            while(x+a[i][p]*n<j*s[i]) x+=a[i][p++]*n;
            b[i][j]={(p-1)*a[i][p]*n+j*s[i]-x,a[i][p]*n};
        }
    }
    for(ll j=1; j<=n; j++){
        pll mn={m+1,1};
        ll t;
        for(ll i=1; i<=n; i++){
            if(p[i]) continue;
            if((ld)b[i][j].F/b[i][j].S<(ld)mn.F/mn.S) mn=b[i][j],t=i;
        }
        if(j<n) cout << mn.F << ' ' << mn.S << '\n';
        p[t]=j;
        q[j]=t;
    }
    for(ll i=1; i<=n; i++) cout << q[i] << ' ';
    cout << '\n';
    return 0;
}

Compilation message

naan.cpp: In function 'int main()':
naan.cpp:72:13: warning: 't' may be used uninitialized in this function [-Wmaybe-uninitialized]
   72 |         q[j]=t;
      |         ~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 460 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 0 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 2 ms 460 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 460 KB Output is correct
33 Correct 1 ms 460 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 460 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 26 ms 11792 KB Output is correct
44 Correct 180 ms 55528 KB Output is correct
45 Correct 111 ms 22968 KB Output is correct
46 Correct 21 ms 4068 KB Output is correct
47 Correct 127 ms 35916 KB Output is correct
48 Correct 98 ms 75204 KB Output is correct
49 Correct 40 ms 24068 KB Output is correct
50 Correct 184 ms 91844 KB Output is correct
51 Correct 103 ms 39496 KB Output is correct
52 Correct 214 ms 81664 KB Output is correct
53 Correct 187 ms 77600 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 39 ms 44036 KB Output is correct
56 Correct 148 ms 53828 KB Output is correct
57 Correct 117 ms 47804 KB Output is correct
58 Correct 156 ms 76560 KB Output is correct
59 Correct 142 ms 43804 KB Output is correct
60 Correct 421 ms 96276 KB Output is correct
61 Correct 374 ms 96224 KB Output is correct
62 Correct 367 ms 96000 KB Output is correct
63 Correct 355 ms 96464 KB Output is correct
64 Correct 366 ms 96208 KB Output is correct
65 Correct 267 ms 96756 KB Output is correct
66 Correct 276 ms 96580 KB Output is correct
67 Correct 264 ms 96572 KB Output is correct
68 Correct 132 ms 55896 KB Output is correct
69 Correct 158 ms 50676 KB Output is correct
70 Correct 148 ms 67396 KB Output is correct
71 Correct 234 ms 72920 KB Output is correct