# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
867562 | YassirSalama | 비밀 (JOI14_secret) | C++17 | 368 ms | 4620 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "secret.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <iomanip>
#include <cmath>
#include <limits>
#include <map>
#include <utility>
#include <cctype>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <functional>
#include <iterator>
using namespace std;
#define OVL(x,s) for(auto y:x) cout<<y<<s; cout<<"\n";
void dbg_out() { cout << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__);
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define ll long long
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define MAX_VALUE 1000000000
vector<int> v;
void Init(int N, int A[]) {
for(int i=0;i<N;i++) v.pb(A[i]);
Secret(0, 1000000000);
}
int ss(int a,int b){
return (a + 2 * (b / 2) < MAX_VALUE) ? (a + 2 * (b / 2)) : MAX_VALUE;
}
int Query(int L, int R) {
int s=v[L];
for(int i=L+1;i<=R;i++) s=ss(s,v[i]);
return s;
}
#ifdef IOI
#include "secret.h"
#include <stdio.h>
#include <stdlib.h>
#define MAX_N 1000
#define MAX_Q 10000
#define MAX_VALUE 1000000000
static int N;
static int A[MAX_N];
static int Q;
static int L[MAX_Q];
static int R[MAX_Q];
static int secret_count;
int Secret(int X, int Y) {
++secret_count;
if (!(0 <= X && X <= MAX_VALUE)) {
fprintf(stderr, "Wrong Answer [1]\n");
exit(0);
}
if (!(0 <= Y && Y <= MAX_VALUE)) {
fprintf(stderr, "Wrong Answer [1]\n");
exit(0);
}
return (X + 2 * (Y / 2) < MAX_VALUE) ? (X + 2 * (Y / 2)) : MAX_VALUE;
}
int main() {
int i, j;
int secret_count_by_init;
int max_secret_count_by_query = 0;
if (1 != scanf("%d", &N)) {
fprintf(stderr, "error: cannot read N.\n");
exit(1);
}
if (!(1 <= N && N <= MAX_N)) {
fprintf(stderr, "error: N is out of bounds.\n");
exit(1);
}
for (i = 0; i < N; ++i) {
if (1 != scanf("%d", &A[i])) {
fprintf(stderr, "error: cannot read A[%d].\n", i);
exit(1);
}
if (!(0 <= A[i] && A[i] <= MAX_VALUE)) {
fprintf(stderr, "error: A[%d] is out of bounds.\n", i);
exit(1);
}
}
if (1 != scanf("%d", &Q)) {
fprintf(stderr, "error: cannot read Q.\n");
exit(1);
}
if (!(0 <= Q && Q <= MAX_Q)) {
fprintf(stderr, "error: Q is out of bounds.\n");
exit(1);
}
for (j = 0; j < Q; ++j) {
if (2 != scanf("%d%d", &L[j], &R[j])) {
fprintf(stderr, "error: cannot read L[%d] and R[%d].\n", j, j);
exit(1);
}
if (!(0 <= L[j] && L[j] <= R[j] && R[j] <= N - 1)) {
fprintf(stderr,
"error: L[%d] and R[%d] do not satisfy the constraints.\n",
j, j);
exit(1);
}
}
secret_count = 0;
Init(N, A);
secret_count_by_init = secret_count;
for (j = 0; j < Q; ++j) {
secret_count = 0;
printf("%d\n", Query(L[j], R[j]));
if (max_secret_count_by_query < secret_count) {
max_secret_count_by_query = secret_count;
}
}
fprintf(stderr, "number of calls to Secret by Init : %d\n",
secret_count_by_init);
fprintf(stderr, "maximum number of calls to Secret by Query : %d\n",
max_secret_count_by_query);
return 0;
}
#endif
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |