제출 #413772

#제출 시각아이디문제언어결과실행 시간메모리
413772abdzag식물 비교 (IOI20_plants)C++17
0 / 100
4040 ms7452 KiB
#include<bits/stdc++.h>
#include<unordered_map>
#include "plants.h"
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define rrep(i,a,b) for(int i=int(a);i>int(b);i--)
#define all(v) v.begin(),v.end()
#define trav(a,v) for(auto&a:v)
#define  sz(a) a.size()
typedef long double ld;
using namespace std;
static const long long inf = 1e15;
typedef long long ll;
typedef unsigned long long ull;
vector<ll> sorted;
void init(int k, std::vector<int> r) {
	ll n = r.size();
	rep(i, 0, n) {
		ll indx = 0;
		rrep(j,n-1,-1){
			if (r[j] == 0) {
				indx = j;
				break;
			}
		}
		indx++;
		ll cur = 0;
		rep(j, 0, n) {
			cur++;
			if (r[(indx + j) % n] == 0) {
				if (cur > k) {
					indx = (j + indx) % n;
					break;
				}
				else cur = 1;
			}
		}
		r[indx] = inf;
		sorted.push_back(indx);
		indx -= (k-1);
		indx += n;
		rep(j, 0, k) {
			r[(indx + j) % n] -= 1;
		}
	}
	reverse(all(sorted));
}

int compare_plants(int x, int y) {
	if (find(all(sorted), x) - find(all(sorted), y) > 0)return 1;
	return -1;
}

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

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:37:13: warning: overflow in conversion from 'long long int' to '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} changes value from '1000000000000000' to '-1530494976' [-Woverflow]
   37 |   r[indx] = inf;
      |             ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...