Submission #1028909

# Submission time Handle Problem Language Result Execution time Memory
1028909 2024-07-20T10:11:20 Z elotelo966 Netrpeljivost (COI23_netrpeljivost) C++17
100 / 100
649 ms 107280 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 12 ms 33316 KB Output is correct
2 Correct 12 ms 33372 KB Output is correct
3 Correct 12 ms 33420 KB Output is correct
4 Correct 12 ms 33216 KB Output is correct
5 Correct 12 ms 33368 KB Output is correct
6 Correct 11 ms 33372 KB Output is correct
7 Correct 11 ms 33368 KB Output is correct
8 Correct 12 ms 33372 KB Output is correct
9 Correct 11 ms 33372 KB Output is correct
10 Correct 11 ms 33228 KB Output is correct
11 Correct 11 ms 33368 KB Output is correct
12 Correct 11 ms 33372 KB Output is correct
13 Correct 12 ms 33368 KB Output is correct
14 Correct 11 ms 33372 KB Output is correct
15 Correct 13 ms 33372 KB Output is correct
16 Correct 16 ms 33368 KB Output is correct
17 Correct 11 ms 33368 KB Output is correct
18 Correct 16 ms 33368 KB Output is correct
19 Correct 12 ms 33324 KB Output is correct
20 Correct 18 ms 33372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 33316 KB Output is correct
2 Correct 12 ms 33372 KB Output is correct
3 Correct 12 ms 33420 KB Output is correct
4 Correct 12 ms 33216 KB Output is correct
5 Correct 12 ms 33368 KB Output is correct
6 Correct 11 ms 33372 KB Output is correct
7 Correct 11 ms 33368 KB Output is correct
8 Correct 12 ms 33372 KB Output is correct
9 Correct 11 ms 33372 KB Output is correct
10 Correct 11 ms 33228 KB Output is correct
11 Correct 11 ms 33368 KB Output is correct
12 Correct 11 ms 33372 KB Output is correct
13 Correct 12 ms 33368 KB Output is correct
14 Correct 11 ms 33372 KB Output is correct
15 Correct 13 ms 33372 KB Output is correct
16 Correct 16 ms 33368 KB Output is correct
17 Correct 11 ms 33368 KB Output is correct
18 Correct 16 ms 33368 KB Output is correct
19 Correct 12 ms 33324 KB Output is correct
20 Correct 18 ms 33372 KB Output is correct
21 Correct 14 ms 34136 KB Output is correct
22 Correct 14 ms 34136 KB Output is correct
23 Correct 14 ms 34040 KB Output is correct
24 Correct 13 ms 33628 KB Output is correct
25 Correct 17 ms 33480 KB Output is correct
26 Correct 14 ms 34140 KB Output is correct
27 Correct 15 ms 34024 KB Output is correct
28 Correct 13 ms 34060 KB Output is correct
29 Correct 21 ms 34140 KB Output is correct
30 Correct 13 ms 34136 KB Output is correct
31 Correct 17 ms 34136 KB Output is correct
32 Correct 15 ms 34140 KB Output is correct
33 Correct 14 ms 33972 KB Output is correct
34 Correct 13 ms 34036 KB Output is correct
35 Correct 14 ms 34092 KB Output is correct
36 Correct 17 ms 34132 KB Output is correct
37 Correct 17 ms 34140 KB Output is correct
38 Correct 13 ms 33960 KB Output is correct
39 Correct 16 ms 33916 KB Output is correct
40 Correct 19 ms 34140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 33316 KB Output is correct
2 Correct 12 ms 33372 KB Output is correct
3 Correct 12 ms 33420 KB Output is correct
4 Correct 12 ms 33216 KB Output is correct
5 Correct 12 ms 33368 KB Output is correct
6 Correct 11 ms 33372 KB Output is correct
7 Correct 11 ms 33368 KB Output is correct
8 Correct 12 ms 33372 KB Output is correct
9 Correct 11 ms 33372 KB Output is correct
10 Correct 11 ms 33228 KB Output is correct
11 Correct 11 ms 33368 KB Output is correct
12 Correct 11 ms 33372 KB Output is correct
13 Correct 12 ms 33368 KB Output is correct
14 Correct 11 ms 33372 KB Output is correct
15 Correct 13 ms 33372 KB Output is correct
16 Correct 16 ms 33368 KB Output is correct
17 Correct 11 ms 33368 KB Output is correct
18 Correct 16 ms 33368 KB Output is correct
19 Correct 12 ms 33324 KB Output is correct
20 Correct 18 ms 33372 KB Output is correct
21 Correct 14 ms 34136 KB Output is correct
22 Correct 14 ms 34136 KB Output is correct
23 Correct 14 ms 34040 KB Output is correct
24 Correct 13 ms 33628 KB Output is correct
25 Correct 17 ms 33480 KB Output is correct
26 Correct 14 ms 34140 KB Output is correct
27 Correct 15 ms 34024 KB Output is correct
28 Correct 13 ms 34060 KB Output is correct
29 Correct 21 ms 34140 KB Output is correct
30 Correct 13 ms 34136 KB Output is correct
31 Correct 17 ms 34136 KB Output is correct
32 Correct 15 ms 34140 KB Output is correct
33 Correct 14 ms 33972 KB Output is correct
34 Correct 13 ms 34036 KB Output is correct
35 Correct 14 ms 34092 KB Output is correct
36 Correct 17 ms 34132 KB Output is correct
37 Correct 17 ms 34140 KB Output is correct
38 Correct 13 ms 33960 KB Output is correct
39 Correct 16 ms 33916 KB Output is correct
40 Correct 19 ms 34140 KB Output is correct
41 Correct 60 ms 39764 KB Output is correct
42 Correct 45 ms 39892 KB Output is correct
43 Correct 52 ms 39764 KB Output is correct
44 Correct 53 ms 39984 KB Output is correct
45 Correct 51 ms 39764 KB Output is correct
46 Correct 47 ms 39764 KB Output is correct
47 Correct 44 ms 39760 KB Output is correct
48 Correct 52 ms 39984 KB Output is correct
49 Correct 46 ms 39780 KB Output is correct
50 Correct 48 ms 39908 KB Output is correct
51 Correct 54 ms 39920 KB Output is correct
52 Correct 49 ms 40016 KB Output is correct
53 Correct 53 ms 39932 KB Output is correct
54 Correct 43 ms 40032 KB Output is correct
55 Correct 44 ms 40016 KB Output is correct
56 Correct 45 ms 39924 KB Output is correct
57 Correct 47 ms 40892 KB Output is correct
58 Correct 58 ms 40020 KB Output is correct
59 Correct 47 ms 40020 KB Output is correct
60 Correct 52 ms 40016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 33316 KB Output is correct
2 Correct 12 ms 33372 KB Output is correct
3 Correct 12 ms 33420 KB Output is correct
4 Correct 12 ms 33216 KB Output is correct
5 Correct 12 ms 33368 KB Output is correct
6 Correct 11 ms 33372 KB Output is correct
7 Correct 11 ms 33368 KB Output is correct
8 Correct 12 ms 33372 KB Output is correct
9 Correct 11 ms 33372 KB Output is correct
10 Correct 11 ms 33228 KB Output is correct
11 Correct 11 ms 33368 KB Output is correct
12 Correct 11 ms 33372 KB Output is correct
13 Correct 12 ms 33368 KB Output is correct
14 Correct 11 ms 33372 KB Output is correct
15 Correct 13 ms 33372 KB Output is correct
16 Correct 16 ms 33368 KB Output is correct
17 Correct 11 ms 33368 KB Output is correct
18 Correct 16 ms 33368 KB Output is correct
19 Correct 12 ms 33324 KB Output is correct
20 Correct 18 ms 33372 KB Output is correct
21 Correct 14 ms 34136 KB Output is correct
22 Correct 14 ms 34136 KB Output is correct
23 Correct 14 ms 34040 KB Output is correct
24 Correct 13 ms 33628 KB Output is correct
25 Correct 17 ms 33480 KB Output is correct
26 Correct 14 ms 34140 KB Output is correct
27 Correct 15 ms 34024 KB Output is correct
28 Correct 13 ms 34060 KB Output is correct
29 Correct 21 ms 34140 KB Output is correct
30 Correct 13 ms 34136 KB Output is correct
31 Correct 17 ms 34136 KB Output is correct
32 Correct 15 ms 34140 KB Output is correct
33 Correct 14 ms 33972 KB Output is correct
34 Correct 13 ms 34036 KB Output is correct
35 Correct 14 ms 34092 KB Output is correct
36 Correct 17 ms 34132 KB Output is correct
37 Correct 17 ms 34140 KB Output is correct
38 Correct 13 ms 33960 KB Output is correct
39 Correct 16 ms 33916 KB Output is correct
40 Correct 19 ms 34140 KB Output is correct
41 Correct 60 ms 39764 KB Output is correct
42 Correct 45 ms 39892 KB Output is correct
43 Correct 52 ms 39764 KB Output is correct
44 Correct 53 ms 39984 KB Output is correct
45 Correct 51 ms 39764 KB Output is correct
46 Correct 47 ms 39764 KB Output is correct
47 Correct 44 ms 39760 KB Output is correct
48 Correct 52 ms 39984 KB Output is correct
49 Correct 46 ms 39780 KB Output is correct
50 Correct 48 ms 39908 KB Output is correct
51 Correct 54 ms 39920 KB Output is correct
52 Correct 49 ms 40016 KB Output is correct
53 Correct 53 ms 39932 KB Output is correct
54 Correct 43 ms 40032 KB Output is correct
55 Correct 44 ms 40016 KB Output is correct
56 Correct 45 ms 39924 KB Output is correct
57 Correct 47 ms 40892 KB Output is correct
58 Correct 58 ms 40020 KB Output is correct
59 Correct 47 ms 40020 KB Output is correct
60 Correct 52 ms 40016 KB Output is correct
61 Correct 582 ms 106644 KB Output is correct
62 Correct 544 ms 106480 KB Output is correct
63 Correct 585 ms 106424 KB Output is correct
64 Correct 637 ms 106420 KB Output is correct
65 Correct 579 ms 106648 KB Output is correct
66 Correct 583 ms 106472 KB Output is correct
67 Correct 598 ms 106576 KB Output is correct
68 Correct 589 ms 106624 KB Output is correct
69 Correct 564 ms 106452 KB Output is correct
70 Correct 603 ms 106484 KB Output is correct
71 Correct 598 ms 107164 KB Output is correct
72 Correct 588 ms 107152 KB Output is correct
73 Correct 595 ms 107280 KB Output is correct
74 Correct 608 ms 107228 KB Output is correct
75 Correct 597 ms 107164 KB Output is correct
76 Correct 544 ms 107056 KB Output is correct
77 Correct 649 ms 107084 KB Output is correct
78 Correct 581 ms 107104 KB Output is correct
79 Correct 576 ms 107160 KB Output is correct
80 Correct 557 ms 107108 KB Output is correct