답안 #782159

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
782159 2023-07-13T15:49:30 Z amirhoseinfar1385 Watermelon (INOI20_watermelon) C++17
0 / 100
6 ms 1368 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);
		}
	}
	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;
      |      ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 980 KB Output is correct
2 Incorrect 6 ms 1368 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 980 KB Output is correct
2 Incorrect 6 ms 1368 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -