답안 #340093

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
340093 2020-12-26T21:43:40 Z MilosMilutinovic 비밀 (JOI14_secret) C++14
0 / 100
542 ms 4736 KB
/**
 *  author: milos
 *  created: 26.12.2020 00:20:30
**/
#include "secret.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> a;

/*int Secret(int l, int r) {
  return l + r;  
}*/

vector<pair<int, pair<vector<int>, vector<int>>>> ans;

int Query(int l, int r) {
  for (auto c : ans) {
    if (c.first >= l && c.first <= r) {
      if (r == c.first) {
        int j = c.first - l;
        return c.second.first[j];
      }
      int j = c.first - l, z = r - c.first - 1;
      return Secret(c.second.first[j], c.second.second[z]);
    }
  }
  return 0;  
}

void Solve(int l, int r) {
  if (l > r) {
    return;
  }
  int mid = l + r >> 1; 
  vector<int> pref, suf;
  int x = a[mid];
  pref.push_back(x);
  for (int i = mid - 1; i >= l; i--) {
    x = Secret(x, a[i]);
    pref.push_back(x);  
  }
  x = a[mid + 1];
  suf.push_back(x);
  for (int i = mid + 2; i <= r; i++) {
    x = Secret(x, a[i]);
    suf.push_back(x);
  }
  ans.push_back({mid, {pref, suf}});
  Solve(l, mid - 1);
  Solve(mid + 1, r);    
}

void Init(int N, int* A) {
  for (int i = 0; i < N; i++) {
    a.push_back(A[i]);
  }
  Solve(0, N - 1);    
}

Compilation message

secret.cpp: In function 'void Solve(int, int)':
secret.cpp:36:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   36 |   int mid = l + r >> 1;
      |             ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 131 ms 2540 KB Wrong Answer: Query(222, 254) - expected : 34031541, actual : 268854015.
2 Incorrect 132 ms 2700 KB Wrong Answer: Query(60, 375) - expected : 669221184, actual : 311474560.
3 Incorrect 132 ms 2672 KB Wrong Answer: Query(211, 401) - expected : 674373968, actual : 353554500.
4 Incorrect 499 ms 4724 KB Wrong Answer: Query(90, 497) - expected : 397934825, actual : 343081568.
5 Incorrect 493 ms 4736 KB Wrong Answer: Query(587, 915) - expected : 752404486, actual : 957013316.
6 Incorrect 491 ms 4588 KB Wrong Answer: Query(738, 741) - expected : 983692994, actual : 850129153.
7 Incorrect 497 ms 4488 KB Wrong Answer: Query(84, 976) - expected : 742463504, actual : 675449873.
8 Incorrect 497 ms 4716 KB Wrong Answer: Query(58, 987) - expected : 20022464, actual : 273091792.
9 Incorrect 493 ms 4588 KB Wrong Answer: Query(33, 967) - expected : 676869696, actual : 827853577.
10 Incorrect 542 ms 4652 KB Wrong Answer: Query(116, 961) - expected : 68487362, actual : 337854787.