Submission #1028912

# Submission time Handle Problem Language Result Execution time Memory
1028912 2024-07-20T10:11:53 Z vjudge1 Netrpeljivost (COI23_netrpeljivost) C++17
100 / 100
537 ms 66388 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define OYY LLONG_MAX
#define mod 998244353
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR for(int i=1;i<=n;i++)
#define mid (start+end)/2
#define lim 2050
#define fi first
#define se second

int n;
int dizi[lim][lim];
int dp[lim][lim];

inline pair<int,int> find(int cur,int x){
	int tut,cev=0;
	for(int i=31;i>=0;i--){
		if((cur&(1ll<<i))!=((cur+1)&(1ll<<i))){
			tut=i;
			cev+=(x&(1ll<<i))?0:(1ll<<i);
			break;
		}
		else cev+=(x&(1ll<<i))?(1ll<<i):0;
	}
	//cout<<cur<<" "<<x<<" "<<tut<<endl;
	return {cev,cev+(1ll<<tut)};
}

inline int f(int sira,int eleman){
	if(sira==n)return 0;
	if(~dp[sira][eleman])return dp[sira][eleman];
	int cev=LLONG_MAX;
	pair<int,int> ara=find(sira,eleman);
	//cout<<sira<<" "<<eleman<<" "<<ara.fi<<" "<<ara.se<<endl;
	for(int i=ara.fi;i<ara.se;i++){
		cev=min(cev,f(sira+1,i)+(f(sira+1,i)==LLONG_MAX?0:dizi[eleman][i]));
	}
	return dp[sira][eleman]=cev;
}

int32_t main(){
	faster
	cin>>n;
	memset(dp,-1,sizeof(dp));
	FOR{
		for(int j=1;j<=n;j++){
			cin>>dizi[i-1][j-1];
		}
	}
	
	int cev=LLONG_MAX;
	
	FOR{
		cev=min(cev,f(0,i-1));
	}
	
	cout<<cev<<'\n';
	
	return 0;
}

Compilation message

Main.cpp: In function 'long long int _Z1fxx.part.0(long long int, long long int)':
Main.cpp:31:22: warning: 'tut' may be used uninitialized in this function [-Wmaybe-uninitialized]
   31 |  return {cev,cev+(1ll<<tut)};
      |                  ~~~~^~~~~~
Main.cpp:21:6: note: 'tut' was declared here
   21 |  int tut,cev=0;
      |      ^~~
Main.cpp:31:22: warning: 'tut' may be used uninitialized in this function [-Wmaybe-uninitialized]
   31 |  return {cev,cev+(1ll<<tut)};
      |                  ~~~~^~~~~~
Main.cpp:21:6: note: 'tut' was declared here
   21 |  int tut,cev=0;
      |      ^~~
Main.cpp:31:22: warning: 'tut' may be used uninitialized in this function [-Wmaybe-uninitialized]
   31 |  return {cev,cev+(1ll<<tut)};
      |                  ~~~~^~~~~~
Main.cpp:21:6: note: 'tut' was declared here
   21 |  int tut,cev=0;
      |      ^~~
Main.cpp:31:22: warning: 'tut' may be used uninitialized in this function [-Wmaybe-uninitialized]
   31 |  return {cev,cev+(1ll<<tut)};
      |                  ~~~~^~~~~~
Main.cpp:21:6: note: 'tut' was declared here
   21 |  int tut,cev=0;
      |      ^~~
Main.cpp:31:22: warning: 'tut' may be used uninitialized in this function [-Wmaybe-uninitialized]
   31 |  return {cev,cev+(1ll<<tut)};
      |                  ~~~~^~~~~~
Main.cpp:21:6: note: 'tut' was declared here
   21 |  int tut,cev=0;
      |      ^~~
Main.cpp: In function 'int32_t main()':
Main.cpp:31:22: warning: 'tut' may be used uninitialized in this function [-Wmaybe-uninitialized]
   31 |  return {cev,cev+(1ll<<tut)};
      |                  ~~~~^~~~~~
Main.cpp:21:6: note: 'tut' was declared here
   21 |  int tut,cev=0;
      |      ^~~
Main.cpp:31:22: warning: 'tut' may be used uninitialized in this function [-Wmaybe-uninitialized]
   31 |  return {cev,cev+(1ll<<tut)};
      |                  ~~~~^~~~~~
Main.cpp:21:6: note: 'tut' was declared here
   21 |  int tut,cev=0;
      |      ^~~
Main.cpp:31:22: warning: 'tut' may be used uninitialized in this function [-Wmaybe-uninitialized]
   31 |  return {cev,cev+(1ll<<tut)};
      |                  ~~~~^~~~~~
Main.cpp:21:6: note: 'tut' was declared here
   21 |  int tut,cev=0;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 11 ms 33368 KB Output is correct
2 Correct 12 ms 33368 KB Output is correct
3 Correct 11 ms 33372 KB Output is correct
4 Correct 11 ms 33372 KB Output is correct
5 Correct 12 ms 33352 KB Output is correct
6 Correct 13 ms 33372 KB Output is correct
7 Correct 12 ms 33372 KB Output is correct
8 Correct 12 ms 33372 KB Output is correct
9 Correct 12 ms 33196 KB Output is correct
10 Correct 12 ms 33368 KB Output is correct
11 Correct 12 ms 33372 KB Output is correct
12 Correct 14 ms 33368 KB Output is correct
13 Correct 12 ms 33368 KB Output is correct
14 Correct 12 ms 33336 KB Output is correct
15 Correct 13 ms 33408 KB Output is correct
16 Correct 11 ms 33372 KB Output is correct
17 Correct 13 ms 33212 KB Output is correct
18 Correct 11 ms 33328 KB Output is correct
19 Correct 14 ms 33368 KB Output is correct
20 Correct 13 ms 33368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 33368 KB Output is correct
2 Correct 12 ms 33368 KB Output is correct
3 Correct 11 ms 33372 KB Output is correct
4 Correct 11 ms 33372 KB Output is correct
5 Correct 12 ms 33352 KB Output is correct
6 Correct 13 ms 33372 KB Output is correct
7 Correct 12 ms 33372 KB Output is correct
8 Correct 12 ms 33372 KB Output is correct
9 Correct 12 ms 33196 KB Output is correct
10 Correct 12 ms 33368 KB Output is correct
11 Correct 12 ms 33372 KB Output is correct
12 Correct 14 ms 33368 KB Output is correct
13 Correct 12 ms 33368 KB Output is correct
14 Correct 12 ms 33336 KB Output is correct
15 Correct 13 ms 33408 KB Output is correct
16 Correct 11 ms 33372 KB Output is correct
17 Correct 13 ms 33212 KB Output is correct
18 Correct 11 ms 33328 KB Output is correct
19 Correct 14 ms 33368 KB Output is correct
20 Correct 13 ms 33368 KB Output is correct
21 Correct 13 ms 33880 KB Output is correct
22 Correct 14 ms 33880 KB Output is correct
23 Correct 13 ms 33840 KB Output is correct
24 Correct 18 ms 33368 KB Output is correct
25 Correct 12 ms 33372 KB Output is correct
26 Correct 13 ms 33748 KB Output is correct
27 Correct 13 ms 33784 KB Output is correct
28 Correct 14 ms 33884 KB Output is correct
29 Correct 14 ms 33832 KB Output is correct
30 Correct 14 ms 33884 KB Output is correct
31 Correct 13 ms 33884 KB Output is correct
32 Correct 13 ms 33784 KB Output is correct
33 Correct 16 ms 33884 KB Output is correct
34 Correct 14 ms 33884 KB Output is correct
35 Correct 14 ms 33880 KB Output is correct
36 Correct 14 ms 33884 KB Output is correct
37 Correct 14 ms 33884 KB Output is correct
38 Correct 13 ms 33884 KB Output is correct
39 Correct 17 ms 33996 KB Output is correct
40 Correct 14 ms 33880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 33368 KB Output is correct
2 Correct 12 ms 33368 KB Output is correct
3 Correct 11 ms 33372 KB Output is correct
4 Correct 11 ms 33372 KB Output is correct
5 Correct 12 ms 33352 KB Output is correct
6 Correct 13 ms 33372 KB Output is correct
7 Correct 12 ms 33372 KB Output is correct
8 Correct 12 ms 33372 KB Output is correct
9 Correct 12 ms 33196 KB Output is correct
10 Correct 12 ms 33368 KB Output is correct
11 Correct 12 ms 33372 KB Output is correct
12 Correct 14 ms 33368 KB Output is correct
13 Correct 12 ms 33368 KB Output is correct
14 Correct 12 ms 33336 KB Output is correct
15 Correct 13 ms 33408 KB Output is correct
16 Correct 11 ms 33372 KB Output is correct
17 Correct 13 ms 33212 KB Output is correct
18 Correct 11 ms 33328 KB Output is correct
19 Correct 14 ms 33368 KB Output is correct
20 Correct 13 ms 33368 KB Output is correct
21 Correct 13 ms 33880 KB Output is correct
22 Correct 14 ms 33880 KB Output is correct
23 Correct 13 ms 33840 KB Output is correct
24 Correct 18 ms 33368 KB Output is correct
25 Correct 12 ms 33372 KB Output is correct
26 Correct 13 ms 33748 KB Output is correct
27 Correct 13 ms 33784 KB Output is correct
28 Correct 14 ms 33884 KB Output is correct
29 Correct 14 ms 33832 KB Output is correct
30 Correct 14 ms 33884 KB Output is correct
31 Correct 13 ms 33884 KB Output is correct
32 Correct 13 ms 33784 KB Output is correct
33 Correct 16 ms 33884 KB Output is correct
34 Correct 14 ms 33884 KB Output is correct
35 Correct 14 ms 33880 KB Output is correct
36 Correct 14 ms 33884 KB Output is correct
37 Correct 14 ms 33884 KB Output is correct
38 Correct 13 ms 33884 KB Output is correct
39 Correct 17 ms 33996 KB Output is correct
40 Correct 14 ms 33880 KB Output is correct
41 Correct 45 ms 37468 KB Output is correct
42 Correct 43 ms 37464 KB Output is correct
43 Correct 53 ms 37460 KB Output is correct
44 Correct 43 ms 37460 KB Output is correct
45 Correct 38 ms 37464 KB Output is correct
46 Correct 44 ms 37464 KB Output is correct
47 Correct 42 ms 37464 KB Output is correct
48 Correct 43 ms 37456 KB Output is correct
49 Correct 57 ms 37448 KB Output is correct
50 Correct 43 ms 37468 KB Output is correct
51 Correct 45 ms 37348 KB Output is correct
52 Correct 47 ms 37468 KB Output is correct
53 Correct 45 ms 37344 KB Output is correct
54 Correct 41 ms 37464 KB Output is correct
55 Correct 43 ms 37460 KB Output is correct
56 Correct 45 ms 37464 KB Output is correct
57 Correct 42 ms 37468 KB Output is correct
58 Correct 43 ms 37392 KB Output is correct
59 Correct 44 ms 37456 KB Output is correct
60 Correct 54 ms 37344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 33368 KB Output is correct
2 Correct 12 ms 33368 KB Output is correct
3 Correct 11 ms 33372 KB Output is correct
4 Correct 11 ms 33372 KB Output is correct
5 Correct 12 ms 33352 KB Output is correct
6 Correct 13 ms 33372 KB Output is correct
7 Correct 12 ms 33372 KB Output is correct
8 Correct 12 ms 33372 KB Output is correct
9 Correct 12 ms 33196 KB Output is correct
10 Correct 12 ms 33368 KB Output is correct
11 Correct 12 ms 33372 KB Output is correct
12 Correct 14 ms 33368 KB Output is correct
13 Correct 12 ms 33368 KB Output is correct
14 Correct 12 ms 33336 KB Output is correct
15 Correct 13 ms 33408 KB Output is correct
16 Correct 11 ms 33372 KB Output is correct
17 Correct 13 ms 33212 KB Output is correct
18 Correct 11 ms 33328 KB Output is correct
19 Correct 14 ms 33368 KB Output is correct
20 Correct 13 ms 33368 KB Output is correct
21 Correct 13 ms 33880 KB Output is correct
22 Correct 14 ms 33880 KB Output is correct
23 Correct 13 ms 33840 KB Output is correct
24 Correct 18 ms 33368 KB Output is correct
25 Correct 12 ms 33372 KB Output is correct
26 Correct 13 ms 33748 KB Output is correct
27 Correct 13 ms 33784 KB Output is correct
28 Correct 14 ms 33884 KB Output is correct
29 Correct 14 ms 33832 KB Output is correct
30 Correct 14 ms 33884 KB Output is correct
31 Correct 13 ms 33884 KB Output is correct
32 Correct 13 ms 33784 KB Output is correct
33 Correct 16 ms 33884 KB Output is correct
34 Correct 14 ms 33884 KB Output is correct
35 Correct 14 ms 33880 KB Output is correct
36 Correct 14 ms 33884 KB Output is correct
37 Correct 14 ms 33884 KB Output is correct
38 Correct 13 ms 33884 KB Output is correct
39 Correct 17 ms 33996 KB Output is correct
40 Correct 14 ms 33880 KB Output is correct
41 Correct 45 ms 37468 KB Output is correct
42 Correct 43 ms 37464 KB Output is correct
43 Correct 53 ms 37460 KB Output is correct
44 Correct 43 ms 37460 KB Output is correct
45 Correct 38 ms 37464 KB Output is correct
46 Correct 44 ms 37464 KB Output is correct
47 Correct 42 ms 37464 KB Output is correct
48 Correct 43 ms 37456 KB Output is correct
49 Correct 57 ms 37448 KB Output is correct
50 Correct 43 ms 37468 KB Output is correct
51 Correct 45 ms 37348 KB Output is correct
52 Correct 47 ms 37468 KB Output is correct
53 Correct 45 ms 37344 KB Output is correct
54 Correct 41 ms 37464 KB Output is correct
55 Correct 43 ms 37460 KB Output is correct
56 Correct 45 ms 37464 KB Output is correct
57 Correct 42 ms 37468 KB Output is correct
58 Correct 43 ms 37392 KB Output is correct
59 Correct 44 ms 37456 KB Output is correct
60 Correct 54 ms 37344 KB Output is correct
61 Correct 537 ms 66180 KB Output is correct
62 Correct 479 ms 66272 KB Output is correct
63 Correct 482 ms 66328 KB Output is correct
64 Correct 513 ms 66288 KB Output is correct
65 Correct 470 ms 66384 KB Output is correct
66 Correct 474 ms 66084 KB Output is correct
67 Correct 512 ms 66364 KB Output is correct
68 Correct 442 ms 66132 KB Output is correct
69 Correct 473 ms 66128 KB Output is correct
70 Correct 524 ms 66132 KB Output is correct
71 Correct 456 ms 66132 KB Output is correct
72 Correct 500 ms 66132 KB Output is correct
73 Correct 456 ms 66320 KB Output is correct
74 Correct 497 ms 66312 KB Output is correct
75 Correct 499 ms 66388 KB Output is correct
76 Correct 468 ms 66132 KB Output is correct
77 Correct 496 ms 66092 KB Output is correct
78 Correct 532 ms 66384 KB Output is correct
79 Correct 481 ms 66132 KB Output is correct
80 Correct 516 ms 66272 KB Output is correct