As title.
ysh
要尬麻
讀題敘
除非你要通靈
確認範圍,是否能暴力解
猜演算法
看輸入
二分搜?
有信心
做啊 等什麼
沒信心
刻暴力解
通靈就是這樣來的
assert
為什麼?
因為區賽題目超級爛
當然也可以用這招作假解
回頭譴責某 TOI
int main() {
int n;cin>>n;
assert(n <= 2e5);
return 0;
}Code
int main() {
int n;cin>>n;
assert(n <= 2e5);
return 0;
}邪教,但有試有機會
舉例來說,時限為一秒
#include<bits/stdc++.h>
using namespace std;
int main() {
auto t = clock();
int ans_for_now = INT_MAX;
int n;cin>>n;
vector<int>f(n);
srand(time(NULL));
for(int &i : f) {
cin>>i;
}
while(clock() - t < 900) {
int l = rand() % n;
int r = rand() % n;
ans_for_now = max(ans_for_now,abs(f.at(l) - f.at(r)));
}
cout<<ans;
return 0;
}#define int long long一樣是邪教
#include<bits/stdc++.h>
using namespace std;
int main() {
int a;cin>>a;
cout<<a;
}#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
int a;cin>>a;
cout<<a;
}可憐
Program received signal SIGSEGV, Segmentation fault.terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc還記得
跟
嗎
恭喜你獲得了傳說中的 RE
有可能…
while 沒有中止但錯誤訊息只有這樣是要怎麼 debug ??
有三招
如果你使用的是 vector 或 deque 可以將 f[i] 改成 f.at(i)
這樣程式在呼叫時會先確認你是不是有戳出去,有的話會直接將程式中止,並輸出以下訊息:
terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check: __n (which is 3) >= this->size() (which is 3)terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check: __n (which is 4294967295) >= this->size() (which is 3)究極黑魔法