Submission #524406

#TimeUsernameProblemLanguageResultExecution timeMemory
524406alirezasamimi100Naan (JOI19_naan)C++17
100 / 100
421 ms96756 KiB
/*#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 (stderr)

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;
      |         ~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...