제출 #1303917

#제출 시각아이디문제언어결과실행 시간메모리
1303917thdh__비밀 (JOI14_secret)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "secret.h" #define ll long long #define pb push_back #define eb emplace_back #define pu push #define ins insert #define fi first #define se second #define all(a) a.begin(),a.end() #define bruh ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define fu(x,a,b) for (auto x=a;x<=b;x++) #define fd(x,a,b) for (auto x=a;x>=b;x--) using namespace std; //mt19937 mt(chrono::steady_clock::now().time_since_epoch().count()); /* Competitive Programming notes that I need to study & fix my dumbass self: 1. Coding: - Always be sure to check the memory of arrays (maybe use vectors), for loops - Always try to maximize the memory if possible, even if you are going for subtasks - Do not exploit #define int long long, it will kill you 2. Stress: - Always try generating big testcases and try if they run 3. Time management: - Don't overcommit or undercommit, always spend a certain amount of time to think a problem, don't just look at it and say I'm fucked - Do not spend too much time coding brute-force solutions, they should be easily-codable solutions that don't take up too much time Time management schedule: Offline / LAH days (4 problems - 3h): 15' thinking of solution / idea 1. no idea: skip 2. yes idea: continue thinking for <= 15' + implementing: <= 20' + brute-force: <= 5' + test generator: <= 5' I hate offline because I am dumb */ typedef pair<int, int> ii; const int N = 1000+5; const int B = 750; const int mod = 1e9+7; using cd = complex<double>; const long double PI = acos(-1); int power(int a,int b) {ll x = 1;if (a >= mod) a%=mod; while (b) {if (b & 1) x = x*a % mod;a = a*a % mod;b>>=1;}return x;} int n; int val[N][N]; void dnc(int l, int r, int& a[]) { if (l == r) { val[l][r] = a[l]; return; } int mid = l+r>>1; int cur = a[mid]; for (int i = mid-1; i >= l; i--) val[i][mid] = Secret(cur, a[i]); cur = a[mid+1]; for (int i = mid+2; i <= r; i++) val[mid+1][i] = Secret(cur, a[i]); dnc(l, mid); dnc(mid+1, r); } void Init(int N, int A[]) { a = A; dnc(1, n, a); } int Query(int l, int r) { int lo = 1, hi = n; while (true) { int mid = lo+hi>>1; if (lo == hi) return a[l]; if (l <= mid && r > mid) return Secret(val[l][mid], val[mid+1][r]); if (r <= mid) hi = mid; else lo = mid+1; } }

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

secret.cpp:57:29: error: declaration of 'a' as array of references
   57 | void dnc(int l, int r, int& a[])
      |                             ^
secret.cpp: In function 'void dnc(...)':
secret.cpp:59:13: error: 'l' was not declared in this scope
   59 |         if (l == r)
      |             ^
secret.cpp:59:18: error: 'r' was not declared in this scope
   59 |         if (l == r)
      |                  ^
secret.cpp:61:29: error: 'a' was not declared in this scope
   61 |                 val[l][r] = a[l];
      |                             ^
secret.cpp:64:19: error: 'l' was not declared in this scope
   64 |         int mid = l+r>>1;
      |                   ^
secret.cpp:64:21: error: 'r' was not declared in this scope
   64 |         int mid = l+r>>1;
      |                     ^
secret.cpp:65:19: error: 'a' was not declared in this scope
   65 |         int cur = a[mid];
      |                   ^
secret.cpp: In function 'void Init(int, int*)':
secret.cpp:73:9: error: 'a' was not declared in this scope
   73 |         a = A;
      |         ^
secret.cpp: In function 'int Query(int, int)':
secret.cpp:83:38: error: 'a' was not declared in this scope
   83 |                 if (lo == hi) return a[l];
      |                                      ^