제출 #103731

#제출 시각아이디문제언어결과실행 시간메모리
103731ekremZalmoxis (BOI18_zalmoxis)C++98
0 / 100
1085 ms100392 KiB
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define N 1000005
using namespace std;

typedef long long ll;
typedef pair < int , int > ii;

int n, k, m, a[N], b[N];
ii ans;
set < ii > s, q;
set < ii > :: iterator it;

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d %d",&n ,&k);
	for(int i = 1; i <= n; i++){
		scanf("%d",a + i);
		q.insert(mp(a[i], i));
		s.insert(mp(i, a[i]));
	}
	while(!q.empty()){
		int kac = q.begin()->st;
		if(kac == 30)
			break;
		int ind = q.begin()->nd;
		// cout << kac << " " << ind << endl;
		it = s.find(mp(ind, kac));
		it++;
		if(it != s.end() and it->nd == kac){
			int ind2 = it->st;
			// cout << "BULDUM " << ind << " " << ind2 << endl;
			s.erase(mp(ind, kac));
			s.erase(mp(ind2, kac));
			s.insert(mp(ind2, kac + 1));
			q.erase(mp(kac, ind));
			q.erase(mp(kac, ind2));
			q.insert(mp(kac + 1, ind2));
		} else{
			// cout << ind << " den sonra " << kac << " ekle" << endl;
			ans = mp(ind, kac);
			break;
			s.erase(mp(ind, kac));
			s.insert(mp(ind, kac + 1));
			q.erase(mp(kac, ind));
			q.insert(mp(kac + 1, ind));
		}
	}
	for(int i = 1; i <= n; i++){
		printf("%d ", a[i]);
		if(i == ans.st)
			printf("%d ", ans.nd);
	}
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n ,&k);
  ~~~~~^~~~~~~~~~~~~~~~
zalmoxis.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",a + i);
   ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...