답안 #72167

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72167 2018-08-26T05:41:42 Z 동진의 (#2167, kdk3776, define_chan, Jinpari) 흔한 자료구조 문제 (FXCUP3_easy) C++17
0 / 100
2 ms 248 KB
#include <stdio.h>
#include <algorithm>
using namespace std;

struct segment_tree
{
	int tree_min[400005];

	void update(int i, int value, int node, int start, int end)
	{
		if (i < start || end < i)
			return;
		else if (start == end)
		{
			tree_min[node] = value;
		}
		else
		{
			int mid = start + end >> 1;
			update(i, value, node * 2, start, mid);
			update(i, value, node * 2 + 1, mid + 1, end);
			tree_min[node] = min(tree_min[node * 2], tree_min[node * 2 + 1]);
		}
	}

	int minValue(int l, int r, int node, int start, int end)
	{
		if (r < start || end < l)
			return 2000000000;
		else if (l <= start && end <= r)
			return tree_min[node];
		else
		{
			int mid = start + end >> 1;
			return min(minValue(l, r, node * 2, start, mid), minValue(l, r, node * 2 + 1, mid + 1, end));
		}
	}
};

segment_tree st;
int arr[100005];

int main()
{
	int n, m;

	scanf(" %d %d", &n, &m);
	for (int i = 1; i <= n; i++)
	{
		scanf(" %d", &arr[i]);
		st.update(i, arr[i], 1, 1, n);
	}
	for (int i = 1; i <= m; i++)
	{
		int a, b;
		scanf(" %d %d", &a, &b);
		printf("%d\n", st.minValue(a, b, 1, 1, n));
	}
	return 0;
}

Compilation message

easy.cpp: In member function 'void segment_tree::update(int, int, int, int, int)':
easy.cpp:19:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    int mid = start + end >> 1;
              ~~~~~~^~~~~
easy.cpp: In member function 'int segment_tree::minValue(int, int, int, int, int)':
easy.cpp:34:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    int mid = start + end >> 1;
              ~~~~~~^~~~~
easy.cpp: In function 'int main()':
easy.cpp:47:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf(" %d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~~
easy.cpp:50:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %d", &arr[i]);
   ~~~~~^~~~~~~~~~~~~~~~
easy.cpp:56:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %d %d", &a, &b);
   ~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -