891 字
4 分钟
0-0初始化
vscode 的设置操作
运行脚本文件
ubutun环境下
这个命令给run.js运行的权限
chmod +x run.sh#!/bin/bash
# 检查是否传入了文件名参数if [ -z "$1" ]; then echo "用法: run.sh 文件名.cpp" exit 1fi
FILE=$1# 去除 .cpp 后缀生成可执行文件名EXE="${FILE%.cpp}"
echo "编译 $FILE..."
# 编译 C++ 文件g++ "$FILE" -std=gnu++20 -O2 -o "$EXE"if [ $? -ne 0 ]; then echo "编译失败!" exit 1fi
echo "编译成功,正在运行..."
# 如果存在 in.txt 文件,则重定向输入if [ -f "in.txt" ]; then ./"$EXE" < in.txt > out.txtelse ./"$EXE"fi
# 比较输出文件 out.txt 和 com.txtecho "正在比较输出文件..."if cmp -s "out.txt" "com.txt"; then echo "Accept (输出一致)"else echo "Wrong Answer (输出不一致)"fi文本缩放
ctrl+, 调出设置,搜索 zoom ,打对勾
ctrl+鼠标滚轮 缩放代码
快捷键配置(待补充)
主函数板子
#include <bits/stdc++.h>#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);#define fix(x) fixed<<setprecision(x)#define endl '\n'#define int long longusing namespace std;using ll = long long;template<class T>using ve = vector<T>;using pii = pair<int, int>;const int N = 1e6 + 10;const int mod = 1e9 + 7;
void solve(){
}
signed main(){ IOS;
int _ = 1; //cin >> _; while (_--) solve(); return 0;}
//------------------------------------// #define ONLINE_JUDGE#ifndef ONLINE_JUDGE ifstream in("./in.txt"); cin.rdbuf(in.rdbuf()); ofstream out("./out.txt"); cout.rdbuf(out.rdbuf());#endif//------------------------------------在ubutun 系统
设置 鼠标大小,灵敏度 调整
对拍
windows系统下
#include <bits/stdc++.h>#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);#define fix(x) fixed<<setprecision(x)#define int long longusing namespace std;using ll = long long;template<class T>using ve = vector<T>;using pii = pair<int, int>;const int N = 1e6 + 10;const int mod = 1e9 + 7;
signed main(){
//编译 system("g++ -O2 a1.cpp -o a1.exe"); system("g++ -O2 a2.cpp -o a2.exe"); system("g++ -O2 data.cpp -o data.exe");
int n=500; for (int i = 1; i <= n; i++) { system("data.exe > data.in"); system("a1.exe < data.in > a1.out"); system("a2.exe < data.in > a2.out");
// 显示当前测试进度 cout<<"test: "<<i<<'\n'; if (system("fc a1.out a2.out > nul")) { cout<<"Wrong Answer!\n";
cout << "\n================== INPUT =================================\n"; ifstream fin("data.in"); cout << fin.rdbuf(); // 直接输出整个文件内容 fin.close();
cout << "\n================== YOUR OUTPUT (a1.out) ==================\n"; ifstream fout1("a1.out"); cout << fout1.rdbuf(); fout1.close();
cout << "\n================== CORRECT OUTPUT (a2.out) ===============\n"; ifstream fout2("a2.out"); cout << fout2.rdbuf(); fout2.close();
cout << "\n================= end ===================================\n"; } else cout<<"Accept!\n"; } return 0;}linux系统下
#include <bits/stdc++.h>#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);#define fix(x) fixed<<setprecision(x)#define int long longusing namespace std;
signed main(){ // 编译,注意没有 .exe system("g++ -O2 a1.cpp -o a1"); system("g++ -O2 a2.cpp -o a2"); system("g++ -O2 data.cpp -o data");
int n = 500; for (int i = 1; i <= n; i++) { // 执行命令时前面要加 ./ 表示当前目录 system("./data > data.in"); system("./a1 < data.in > a1.out"); system("./a2 < data.in > a2.out");
cout << "test: " << i << '\n';
// 使用 diff 进行对比,> /dev/null 表示隐藏输出 if (system("diff a1.out a2.out > /dev/null")) { cout << "Wrong Answer!\n";
cout << "\n================== INPUT =================================\n"; ifstream fin("data.in"); cout << fin.rdbuf(); fin.close();
cout << "\n================== YOUR OUTPUT (a1.out) ==================\n"; ifstream fout1("a1.out"); cout << fout1.rdbuf(); fout1.close();
cout << "\n================== CORRECT OUTPUT (a2.out) ===============\n"; ifstream fout2("a2.out"); cout << fout2.rdbuf(); fout2.close();
cout << "\n================= end ===================================\n"; break; // 出错就退出循环 } else cout << "Accept!\n"; }
return 0;}数据生成器
#include <bits/stdc++.h>#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);#define fix(x) fixed<<setprecision(x)#define int long longusing namespace std;using ll = long long;template<class T>using ve = vector<T>;using pii = pair<int, int>;const int N = 1e6 + 10;const int mod = 1e9 + 7;
// 创建随机设备和随机数生成器mt19937 rng(random_device{}());
// 生成 [l, r] 区间的随机整数int randint(int l, int r){ return uniform_int_distribution<int>(l, r)(rng);}
// 生成长度为len的字符串 [ ]string randstring(int len){ // 大写,数字,修改 randint('a','z'); string res; for (int i = 0; i < len; ++i) res += char(randint('a', 'z')); return res;}
//创建n个节点的树,无重边,无自环void get_tree(int n){ ve<int>a(n+1); iota(a.begin(),a.end(),0); shuffle(a.begin()+1,a.end(),rng); for(int i=1;i<=n;i++) cout<<a[i]<<" \n"[i==n]; ve<pii>f; for(int i=2;i<=n;i++) {//连接,点u和前面的某一个点 int u=a[i]; int v=a[randint(1,i-1)]; f.push_back({v,u}); } cout<<n<<'\n'; for(auto [u,v]:f) cout<<u<<" "<<v<<"\n";}
void solve(){ int x=randint(0,20); cout<<x<<'\n';}
signed main(){ IOS; int _ = 1; //_=randint(1,10); while (_--) solve(); return 0;}