Submission #782167

# Submission time Handle Problem Language Result Execution time Memory
782167 2023-07-13T15:55:37 Z amirhoseinfar1385 Watermelon (INOI20_watermelon) C++17
31 / 100
12 ms 2760 KB
#include<bits/stdc++.h>
using namespace std;
int n,m;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	vector<int>all(n);
	for(int i=0;i<n;i++){
		cin>>all[i];
	}
	vector<int>res(n+1);
	vector<int>allv;
	for(int i=0;i<n;i++){
		if(all[i]==-1){
			allv.push_back(i);
		}
	}
	int now=n;
	for(int i=0;i<(int)allv.size();i++){
		res[allv[i]]=now;
		now--;
	}
	now=1;
	int last=-1;
	vector<int>st;
	for(int j=0;j<n;j++){
		if(all[j]==1){
			res[j]=now;
			now++;
			int z=2;
			while((int)st.size()>0){
				auto x=st.back();
				if(all[x]==z){
					z++;
					res[x]=now;
					st.pop_back();
					now++;
					continue;
				}
				break;
			}
		}	
		if(all[j]!=1&&all[j]!=-1){
			st.push_back(j);
		}
	}
	if((int)st.size()>0){
		cout<<-1<<"\n";
		return 0;
	}
	for(int i=0;i<n;i++){
		cout<<res[i]<<" ";
	}
	cout<<"\n";
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:27:6: warning: unused variable 'last' [-Wunused-variable]
   27 |  int last=-1;
      |      ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Incorrect 0 ms 212 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Incorrect 0 ms 212 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 980 KB Output is correct
2 Correct 3 ms 1108 KB Output is correct
3 Correct 6 ms 1108 KB Output is correct
4 Correct 4 ms 1356 KB Output is correct
5 Correct 7 ms 1108 KB Output is correct
6 Correct 5 ms 1100 KB Output is correct
7 Correct 5 ms 1108 KB Output is correct
8 Correct 5 ms 1108 KB Output is correct
9 Correct 5 ms 1108 KB Output is correct
10 Correct 7 ms 1040 KB Output is correct
11 Correct 11 ms 1876 KB Output is correct
12 Correct 11 ms 1868 KB Output is correct
13 Correct 10 ms 1876 KB Output is correct
14 Correct 11 ms 1860 KB Output is correct
15 Correct 7 ms 2260 KB Output is correct
16 Correct 7 ms 2192 KB Output is correct
17 Correct 7 ms 2264 KB Output is correct
18 Correct 7 ms 2264 KB Output is correct
19 Correct 7 ms 2252 KB Output is correct
20 Correct 7 ms 2244 KB Output is correct
21 Correct 7 ms 2264 KB Output is correct
22 Correct 7 ms 2264 KB Output is correct
23 Correct 7 ms 2264 KB Output is correct
24 Correct 12 ms 2380 KB Output is correct
25 Correct 12 ms 2376 KB Output is correct
26 Correct 12 ms 2392 KB Output is correct
27 Correct 12 ms 2324 KB Output is correct
28 Correct 12 ms 2372 KB Output is correct
29 Correct 12 ms 2372 KB Output is correct
30 Correct 4 ms 724 KB Output is correct
31 Correct 6 ms 1108 KB Output is correct
32 Correct 10 ms 1868 KB Output is correct
33 Correct 11 ms 1996 KB Output is correct
34 Correct 1 ms 468 KB Output is correct
35 Correct 3 ms 584 KB Output is correct
36 Correct 6 ms 1232 KB Output is correct
37 Correct 11 ms 2004 KB Output is correct
38 Correct 11 ms 2040 KB Output is correct
39 Correct 11 ms 2004 KB Output is correct
40 Correct 11 ms 2256 KB Output is correct
41 Correct 12 ms 2760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 980 KB Output is correct
2 Correct 3 ms 1108 KB Output is correct
3 Correct 6 ms 1108 KB Output is correct
4 Correct 4 ms 1356 KB Output is correct
5 Correct 7 ms 1108 KB Output is correct
6 Correct 5 ms 1100 KB Output is correct
7 Correct 5 ms 1108 KB Output is correct
8 Correct 5 ms 1108 KB Output is correct
9 Correct 5 ms 1108 KB Output is correct
10 Correct 7 ms 1040 KB Output is correct
11 Correct 11 ms 1876 KB Output is correct
12 Correct 11 ms 1868 KB Output is correct
13 Correct 10 ms 1876 KB Output is correct
14 Correct 11 ms 1860 KB Output is correct
15 Correct 7 ms 2260 KB Output is correct
16 Correct 7 ms 2192 KB Output is correct
17 Correct 7 ms 2264 KB Output is correct
18 Correct 7 ms 2264 KB Output is correct
19 Correct 7 ms 2252 KB Output is correct
20 Correct 7 ms 2244 KB Output is correct
21 Correct 7 ms 2264 KB Output is correct
22 Correct 7 ms 2264 KB Output is correct
23 Correct 7 ms 2264 KB Output is correct
24 Correct 12 ms 2380 KB Output is correct
25 Correct 12 ms 2376 KB Output is correct
26 Correct 12 ms 2392 KB Output is correct
27 Correct 12 ms 2324 KB Output is correct
28 Correct 12 ms 2372 KB Output is correct
29 Correct 12 ms 2372 KB Output is correct
30 Correct 4 ms 724 KB Output is correct
31 Correct 6 ms 1108 KB Output is correct
32 Correct 10 ms 1868 KB Output is correct
33 Correct 11 ms 1996 KB Output is correct
34 Correct 1 ms 468 KB Output is correct
35 Correct 3 ms 584 KB Output is correct
36 Correct 6 ms 1232 KB Output is correct
37 Correct 11 ms 2004 KB Output is correct
38 Correct 11 ms 2040 KB Output is correct
39 Correct 11 ms 2004 KB Output is correct
40 Correct 11 ms 2256 KB Output is correct
41 Correct 12 ms 2760 KB Output is correct
42 Incorrect 6 ms 1108 KB Output isn't correct
43 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Incorrect 0 ms 212 KB Output isn't correct
13 Halted 0 ms 0 KB -