随笔分类 - CUGBACM
摘要:1. const int maxn = 1e6+10; bool is_not_pri[maxn]; int dp[maxn], tol; void presolve(){ is_not_pri[1] = true; for(int i=2; i<maxn; i++){ if(is_not_pri[
阅读全文
摘要:1. #define int long long const int maxn = 4e4+10; int n, ml, mr, inf = 1e10, tol, dis[1010]; struct Edge{ int u, v, w; }; Edge edge[maxn]; void solve(
阅读全文
摘要:codeforces 1. void solve(){ int l, r, u, d; cin >> l >> r >> u >> d; if(l == r && u == d && l == u){ cout << "YES" << endl; }else{ cout << "NO" << end
阅读全文
摘要:#define int long long void solve(){ int n; cin >> n; int ans = 0; for(int i=1; i<=n; i++){ int l = i; int r = n/(n/i); int len = r-l+1; ans += len*(n/
阅读全文
摘要:1. Good Key, Bad Key #define int long long const int maxn = 1e5+10; int n, k, a[maxn]; void solve(){ cin >> n >> k; vector<int> dp(n+1, 0); int mx = 0
阅读全文
摘要:1. King Bombee #define int long long const int maxn = 2e3+10; int n, m, k, s, t, x, p = 998244353; vector<vector<int>> tree; int dp[maxn][maxn][2]; vo
阅读全文
摘要:1.Long Inversions void solve(){ int n; cin >> n; string s; cin >> s; s = ' '+s; int ans = 1; for(int k=n; k>=2; k--){ vector<int> dif(n+k+1, 0); for(i
阅读全文
摘要:1. Light Switches const int maxn = 2e5+10; int a[maxn], n, k; void solve(){ cin >> n >> k; int t = 2*k, mx = 0; set<int> q; for(int i=0;i <n; i++){ ci
阅读全文
摘要:爽玩 1. Find the Permutation void solve(){ int n; cin >> n; string s[n]; for(int i=0; i<n; i++) cin >> s[i]; int ans[n]; for(int i=0; i<n; i++){ ans[i]
阅读全文
摘要:codeforces 1. The Play Never Ends void solve(){ int n; cin >> n; if(n%3 == 1){ cout << "YES" << endl; }else{ cout << "NO" << endl; } } 2. Perfecto voi
阅读全文
摘要:codeforces 3. Limited Repainting const int maxn = 3e5+10; int n, k, a[maxn]; string s; bool check(int mx){ int len = 0, cnt = 0; bool not_need = true;
阅读全文
摘要:Codeforces 1. Swap Columns and Find a Path #define int long long void solve(){ int n; cin >> n; int a[2][n+2], cnt = 0; a[0][0] = a[1][0] = a[0][n+1]
阅读全文
摘要:Codeforces Round 1006 (Div. 3) 1. New World, New Me, New Array int n, k, p; void solve(){ cin >> n >> k >> p; if((k>0 && n*p < k )|| (k<0 && -n*p > k)
阅读全文
摘要:AtCoder 1. Paint to make a rectangle void solve(){ int h, w; cin >> h >> w; string a[h]; for(int i=0; i<h; i++) cin >> a[i]; int mxx = 0, mxy = 0, mnx
阅读全文
摘要:爆学数据库的一天 Codeforces 1. Shashlik Cooking void solve(){ int n, k; cin >> n >> k; int len = 2*k+1; if(n % len <= k && n%len != 0){ cout << n/len+1 << end
阅读全文
摘要:Codeforces Round 1005 (Div. 2) 1. Brogramming Contest void solve(){ int len; cin >> len; string s; cin >> s; s = '0'+s; len += 2; int cnt = 0; for(int
阅读全文
摘要:1. Is It A Tree?-树,并查集 题意 给定多条有向边的图,问这个图是不是一个树 思路 有两种思路 一种是用邻接表构建这个图,然后以入度为 0 的点为根,遍历这个图 如果入度为 0 的点有多个,或者在遍历的时候访问到了已经访问过的点,则不是一棵树 另一种思路就是用并查集 如果合并的时候两
阅读全文

浙公网安备 33010602011771号