跳到正文

个人记录

CSP-J2022游记

IGJHL约 13 分钟
原文
文章信息与版本

文章信息

发布
2022年10月30日
收录
2026年11月16日
更新
2026年11月16日
篇幅
约 13 分钟

版本

  1. v1当前

第二次参加 CSP−JCSP-J 了,上次 freopen 注释没删保灵了。

Day -191980

初赛,家里考非常的轻松。很快啊,晚上回学校赶作业。

Day -114514

出成绩了,J78.5J78.5,SS 差 1.51.5。

Day -7

进行了一个废的颓。

Day 1

早上 77 点不到就起来了,2020 多分钟到了耀华,又见到了 FLY_Lai 和 奆翁等。

然后进了耀华。

考场门口排队…

开始考试,正序开题,T1T1 非常的简单,开个 long long 再判个 11,直接模拟即可。T2T2 显然要求单次查询 O(log⁡n)O(\log n) 以内。 很容易推出 p+q=mp + q = m 且 pq=npq = n,设 p,qp,q 为一元二次方程 (x−p)(x−q)=x2−mx+pq(x - p)(x - q) = x^2 - mx + pq 两根,那么需要 Δ=m2−4n≥0\Delta = m^2 - 4n \ge 0,故 x1,x2=m±Δ2x_1,x_2 = \frac {m \pm \sqrt{\Delta}}{2},要让 x1,x2x_1,x_2 有整数解,就要让 Δ=k2 (k∈Z)\Delta = k^2\ (k \in Z),且 m±Δ=0 (mod 2)m \pm \sqrt \Delta = 0\ (mod\ 2)。

由此 O(1)O(1) 判断即可。

T3T3 不会(或许要建表达式树?但忘了),拿了点部分分(伏笔)。

部分分非常的不好拿,打了一个多小时,才拿了 2020 左右。

然后弄 T4T4,看完题目感觉非常可做,但想了想还是先打了 k=0k = 0 的部分分。

打完了,还剩 23 min23\ min。

5 min5\ min 左右,想到了正解(大概,至少 Lai 是这么做的)。

dpi,jdp_{i, j} 表示前 1∼i1 \sim i 个点中,添了 jj 个点的最长上升点列, 枚举一遍转移即可。

但看时间不多了,便没打,检查了一下其他问题就开始玩小恐龙。

很快啊,考完了,问了问 Lai 他估分 315,奆翁说他逆序开题 T3T3 看不懂,竟然没 AK,我和 Lai 都很诧异。又遇到了 5+*,他竟然会打 T3 50T3\ 50 分,途中遇到的 深中学子 都是 300+300 +,这就是玩老鹰捉小鸡的深中初一学子吗(。

下午回家继续颓嘿嘿。

估分

100+100+20+40=260100 + 100 + 20 + 40 = 260

实际

100+0+15+35=150100 + 0 + 15 + 35 = 150

1=无了,T2手玩函数单调区间后打错了,g。

代码

C++
#include <iostream>

#define int long long

using namespace std;

const int inf = 1e9;

signed main() {
    int a, b;
    
    cin >> a >> b;
    
    if (a == 1)
        return cout << 1, 0;
    
    int s = 1;
    
    while (s <= inf && b > 0) {
        s *= a, -- b;
    }
    
    if (s > inf && b >= 0)
        cout << -1;
    else
        cout << s;
        
    return 0;
}
C++
#include <iostream>
#include <cstdio>

#define int long long

using namespace std;

signed main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	 
	freopen("decode.in", "r", stdin);
	freopen("decode.out", "w", stdout);
	
	int k;
	
	cin >> k;
	
	while (k --) {
		int n, d, e;
		
		cin >> n >> d >> e;
		
		int m = n - (d * e) + 2;
		
		int l = 1, r = m;
		
		while (r - l > 1) {
			int mid = (l + r) / 2;
			
			if (mid * (m - mid) - mid - (m - mid) + 2 <= d * e)
				l = mid;
			else
				r = mid;
		}
		
		if (l * (m - l) == n && (l - 1) * (m - l - 1) + 1 == d * e)
			cout << l << " " << m - l << "\n";
		else
			cout << "NO\n";
	}
	
	return 0;
}
C++
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	freopen("expr.in", "r", stdin);
	freopen("expr.out", "w", stdout);
	string s;
	
	cin >> s;
	
	if (s.size() == 3) {//|s| = 3时 
		if (s[0] == '(')
			cout << (s[1] - '0') << "\n0 0";
		else
			if (s[1] == '&') {
				cout << ((s[0] - '0') & (s[2] - '0')) << "\n";
				
				if (s[0] == '0')
					cout << "1 0";
				else
					cout << "0 0";
			}
			else {
				if (s[0] == '1')
					cout << "1\n0 1";
				else
					if (s[2] == '1')
						cout << "1\n0 0";
					else
						cout << "0\n0 0";
			}
	}
	
	if (s.size() == 5) {//|s| = 5时 
		if (s[1] == '(' && s[0] == '(') {//((x)) 式 
			cout << (s[2] - '0') << "\n0 0";
		}
		else if (s[4] == ')') {//(a ? b)式 
			if (s[2] == '&') {
				cout << ((s[1] - '0') & (s[3] - '0')) << "\n";
			
			if (s[1] == '0')
				cout << "1 0";
			else
				cout << "0 0";
			}
			else {
				if (s[1] == '1')
					cout << "1\n0 1";
				else
					if (s[3] == '1')
						cout << "1\n0 0";
					else
						cout << "0\n0 0";
			}
		}
		else if (s[2] == ')') {//(a) ? b式 
			if (s[3] == '|') {
				if (s[1] == '1')
					cout << "1\n0 1";
				else
					if (s[4] == '1')
						cout << "1\n0 0";
					else
						cout << "0\n0 0";
			}
			else {
				if (s[1] == '0')
					cout << "0\n1 0";
				else
					if (s[4] == '0')
						cout << "0\n0 0";
					else
						cout << "1\n0 0";
			}
		}
		else if (s[2] == '(') {//a ? (b)式 
			if (s[1] == '|') {
				if (s[0] == '1')
					cout << "1\n0 1";
				else
					if (s[3] == '0')
						cout << "0\n0 0";
					else
						cout << "1\n0 0";
			}
			else {
				if (s[0] == '0')
					cout << "0\n1 0";
				else
					if (s[3] == '0')
						cout << "0\n0 0";
					else
						cout << "1\n0 0";
			}
		}
		else {//a ? b ? c式 
			if (s[1] == '|' && s[3] == '|')//a | b | c
				if (s[0] == '1' || s[2] == '1')
					cout << "1\n0 1";
				else
					if (s[3] == '1')
						cout << "1\n0 0";
					else
						cout << "0\n0 0";
			
			if (s[1] == '&' && s[3] == '|') {//a & b | c
				if (s[0] == '0' && s[2] == '0' && s[4] == '0')
					cout << "0\n1 0";
				if (s[0] == '0' && s[2] == '0' && s[4] == '1')
					cout << "1\n1 0";
				if (s[0] == '0' && s[2] == '1' && s[4] == '0')
					cout << "0\n1 0";
				if (s[0] == '0' && s[2] == '1' && s[4] == '1')
					cout << "1\n1 0";
				if (s[0] == '1' && s[2] == '0' && s[4] == '0')
					cout << "0\n0 0";
				if (s[0] == '1' && s[2] == '0' && s[4] == '1')
					cout << "1\n0 0";
				if (s[0] == '1' && s[2] == '1' && s[4] == '0')
					cout << "1\n0 1";
				if (s[0] == '1' && s[2] == '1' && s[4] == '1')
					cout << "1\n0 1";
			}
			
			if (s[1] == '|' && s[3] == '&') {//a | b & c 
				if (s[0] == '0' && s[2] == '0' && s[4] == '0')
					cout << "0\n0 0";
				if (s[0] == '0' && s[2] == '0' && s[4] == '1')
					cout << "1\n0 0";
				if (s[0] == '0' && s[2] == '1' && s[4] == '0')
					cout << "0\n0 0";
				if (s[0] == '0' && s[2] == '1' && s[4] == '1')
					cout << "1\n0 0";
				if (s[0] == '1' && s[2] == '0' && s[4] == '0')
					cout << "1\n0 1";
				if (s[0] == '1' && s[2] == '0' && s[4] == '1')
					cout << "1\n1 1";
				if (s[0] == '1' && s[2] == '1' && s[4] == '0')
					cout << "1\n0 1";
				if (s[0] == '1' && s[2] == '1' && s[4] == '1')
					cout << "1\n0 1";
			}
			
			if (s[1] == '&' && s[3] == '&')//a & b & c
				if (s[0] == '0' || s[2] == '0')
					cout << "0\n1 0";
				else
					if (s[3] == '0')
						cout << "0\n0 0";
					else
						cout << "1\n0 0";
		}
	}
	
	return 0;
}
C++
#include <iostream>
#include <algorithm>

#define int long long

using namespace std;

const int N = 500 + 5;

struct node {
    int x, y;
} a[N];

bool dis(int i, int j) {
	return ((a[i].x - a[j].x) * (a[i].x - a[j].x) + (a[i].y - a[j].y) * (a[i].y - a[j].y)) == 1;
}

int f[N];

signed main() {
    int n, k;
    
    cin >> n >> k;
    
    if (k == 0) {
        f[1] = 1;
        
        for (int i = 1; i <= n; ++ i)
            cin >> a[i].x >> a[i].y;
        
        sort(a + 1, a + n + 1, [](node x, node y){return (x.x != y.x) ? (x.x < y.x) : (x.y < y.y);});
        
        for (int i = 1; i <= n; ++ i)
            for (int j = 1; j < i; ++ j)
                if (dis(i, j))
                    f[i] = max(f[i], f[j] + 1);
        
        int ans = 0;
        
        for (int i = 1; i <= n; ++ i)
            ans = max(f[i], ans);
        
        cout << ans;
    }
    else
        cout << n + k;
        
    return 0;
}
原文
抓取于
  1. NOIP_primer

    T2为啥G了

  2. IGJHL

    好欸,T2g掉

  3. FLY_lai

    T3没有35,只有15

  4. rlc202204

    其实我感觉我T3貌似挂到15到30了…