Submission #72167

#TimeUsernameProblemLanguageResultExecution timeMemory
72167동진의 (#118)Easy Data Structure Problem (FXCUP3_easy)C++17
0 / 100
2 ms248 KiB
#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 (stderr)

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);
   ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...