大家帮我看看我的码风

确实,我一写就上百行,但实际上没啥内容,全是换行

2 个赞

让别人以为我们写代码非常的认真,这就是前面一堆define的作用

1 个赞

哈哈哈雀氏

2 个赞

曾经有段时间我特别喜欢压行:

#include<bits/stdc++.h>
using namespace std;
long long a[200005],sum[200005],d[200005];
struct date{
    long long id,value;
}b[200005];
bool cmp(date x,date y){return x.value<y.value;}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int t;
    cin>>t;
    while(t--){
        int n,c;
        cin>>n>>c;
        for(int i=1;i<=n;++i){
            cin>>a[i],b[i].value=a[i]+min(i,n-i+1);
            b[i].id=i;
        }
        sort(b+1,b+n+1,cmp);
        for(int i=1;i<=n;++i){
            sum[i]=sum[i-1]+b[i].value;
            d[b[i].id]=i;
        }
        int ans=0;
        for(int i=1;i<=n;++i){
            int l=0,r=n;
            if(a[i]+i>c) continue;
            while(l<r){
                int mid=(l+r+1)/2;
                long long w=sum[mid]+a[i]+i;
                if(mid>=d[i]) 
                    w-=b[d[i]].value;
                if(w<=c) l=mid;
                else r=mid-1;
            }
            if(l<d[i]) ++l;
            ans=max(ans,l);
        }
        cout<<ans<<'\n';
    }
    return 0;
}

可读性-=1e5

1 个赞

话说我的N,喜欢用 const int
你们呢。

  • #define N 100005
  • const int N=1e5+5
  • int a[100005]
0 投票人
1 个赞

火车头差评!

1 个赞

这个变量名如何呢(

#include<bits/stdc++.h>
#define int long long

using namespace std;

// 定义字符串对数组,用于存储替换规则
pair<string, string> replacement_rules_from_a_to_b[15], replacement_rules_from_b_to_a[15];

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    
    string input_string_a, input_string_b;
    cin >> input_string_a >> input_string_b;  // 输入两个字符串a和b
    
    string replacement_string_1, replacement_string_2;
    int total_replacement_rules = 0;
    // 读取替换规则
    while (cin >> replacement_string_1 >> replacement_string_2) {
        replacement_rules_from_a_to_b[++total_replacement_rules] = {replacement_string_1, replacement_string_2};  // 存储替换规则,replacement_rules_from_a_to_b[i]表示从replacement_string_1替换为replacement_string_2
        replacement_rules_from_b_to_a[total_replacement_rules] = {replacement_string_2, replacement_string_1};    // replacement_rules_from_b_to_a[i]表示从replacement_string_2替换为replacement_string_1
    }
    
    queue<pair<string, int>> queue_from_a, queue_from_b;  // queue_from_a和queue_from_b分别为存储a字符串和b字符串的队列
    map<string, int> visited_strings_from_a, visited_strings_from_b;  // visited_strings_from_a和visited_strings_from_b分别记录a和b字符串是否已访问过
    
    int max_search_depth = 10;  // 最大搜索深度设为10
    queue_from_a.push({input_string_a, 0});  // 初始化队列queue_from_a,存储input_string_a及其步数0
    queue_from_b.push({input_string_b, 0});  // 初始化队列queue_from_b,存储input_string_b及其步数0
    visited_strings_from_a[input_string_a] = 1, visited_strings_from_b[input_string_b] = 1;  // 标记input_string_a和input_string_b已访问
    
    while (max_search_depth--) {  // 进行最多10次深度搜索
        if (queue_from_a.size() <= queue_from_b.size()) {  // 如果队列queue_from_a的大小小于等于queue_from_b,则扩展queue_from_a队列
            int current_queue_size = queue_from_a.size();
            while (current_queue_size--) {
                string current_string = queue_from_a.front().first;  // 当前处理的字符串current_string
                int current_step = queue_from_a.front().second;  // 当前步数current_step
                queue_from_a.pop();
                
                // 遍历所有替换规则
                for (int i = 1; i <= total_replacement_rules; i++) {
                    int string_length = current_string.size(), rule_length = replacement_rules_from_a_to_b[i].first.size();
                    for (int j = 0; j + rule_length - 1 < string_length; j++) {
                        if (current_string.substr(j, rule_length) == replacement_rules_from_a_to_b[i].first) {  // 如果找到匹配的子字符串
                            string new_string = current_string.substr(0, j) + replacement_rules_from_a_to_b[i].second + current_string.substr(j + rule_length);  // 进行替换
                            
                            if (visited_strings_from_a[new_string] != 0)  // 如果替换后的字符串new_string已经访问过,跳过
                                continue;
                            else if (visited_strings_from_b[new_string] != 0) {  // 如果new_string在队列queue_from_b中已经出现过,说明找到解
                                cout << 10 - max_search_depth;
                                return 0;
                            } else {
                                queue_from_a.push({new_string, current_step + 1});  // 将新的字符串new_string加入队列queue_from_a
                                visited_strings_from_a[new_string] = 1;  // 标记new_string已访问
                            }
                        }
                    }
                }
            }
        } else {  // 否则扩展queue_from_b队列
            int current_queue_size = queue_from_b.size();
            while (current_queue_size--) {
                string current_string = queue_from_b.front().first;  // 当前处理的字符串current_string
                int current_step = queue_from_b.front().second;  // 当前步数current_step
                queue_from_b.pop();
                
                // 遍历所有替换规则
                for (int i = 1; i <= total_replacement_rules; i++) {
                    int string_length = current_string.size(), rule_length = replacement_rules_from_b_to_a[i].first.size();
                    for (int j = 0; j + rule_length - 1 < string_length; j++) {
                        if (current_string.substr(j, rule_length) == replacement_rules_from_b_to_a[i].first) {  // 如果找到匹配的子字符串
                            string new_string = current_string.substr(0, j) + replacement_rules_from_b_to_a[i].second + current_string.substr(j + rule_length);  // 进行替换
                            
                            if (visited_strings_from_b[new_string] != 0)  // 如果替换后的字符串new_string已经访问过,跳过
                                continue;
                            else if (visited_strings_from_a[new_string] != 0) {  // 如果new_string在队列queue_from_a中已经出现过,说明找到解
                                cout << 10 - max_search_depth;
                                return 0;
                            } else {
                                queue_from_b.push({new_string, current_step + 1});  // 将新的字符串new_string加入队列queue_from_b
                                visited_strings_from_b[new_string] = 1;  // 标记new_string已访问
                            }
                        }
                    }
                }
            }
        }
    }
    
    cout << "NO ANSWER!";  // 如果没有找到解,输出"NO ANSWER!"
}
1 个赞

不能多选吗?一般我用第三种,当数组特别多时我用第二种

1 个赞

懒得打字。。。。

1 个赞

不,看这个代码如何。

#include<bits/stdc++.h>
using namespace std;
long long n,s;
namespace Fread
{
	const int SIZE = 1 << 16;
	char buf[SIZE], *S, *T;
	inline char getchar() { if (S == T) { T = (S = buf) + fread(buf, 1, SIZE, stdin); if (S == T) return '\n'; } return *S++; }
}
using namespace Fread;
namespace Fwrite
{
	const int SIZE = 1 << 16;
	char buf[SIZE], *S = buf, *T = buf + SIZE;
	inline void flush() { fwrite(buf, 1, S - buf, stdout); S = buf; }
	inline void putchar(char c) { *S++ = c; if (S == T) flush(); }
	struct NTR { ~NTR() { flush(); } } ztr;
}
using namespace Fwrite;
#define getchar Fread::getchar
#define putchar Fwrite::putchar
namespace Fastio
{
	struct Reader
	{
		template <typename T> Reader& operator >> (T &x)
		{
			x = 0;
			short f = 1;
			char c = getchar();
			while (c < '0' || c > '9') { if (c == '-') f *= -1; c = getchar(); }
			while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
			x *= f;
			return *this;
		}
		Reader& operator >> (double &x)
		{
			x = 0;
			double t = 0;
			short f = 1, s = 0;
			char c = getchar();
			while ((c < '0' || c > '9') && c != '.') { if (c == '-') f *= -1; c = getchar(); }
			while (c >= '0' && c <= '9' && c != '.') x = x * 10 + (c ^ 48), c = getchar();
			if (c == '.') c = getchar();
			else { x *= f; return *this; }
			while (c >= '0' && c <= '9') t = t * 10 + (c ^ 48), s++, c = getchar();
			while (s--) t /= 10.0;
			x = (x + t) * f;
			return *this;
		}
		Reader& operator >> (long double &x)
		{
			x = 0;
			long double t = 0;
			short f = 1, s = 0;
			char c = getchar();
			while ((c < '0' || c > '9') && c != '.') { if (c == '-') f *= -1; c = getchar(); }
			while (c >= '0' && c <= '9' && c != '.') x = x * 10 + (c ^ 48), c = getchar();
			if (c == '.') c = getchar();
			else { x *= f; return *this; }
			while (c >= '0' && c <= '9') t = t * 10 + (c ^ 48), s++, c = getchar();
			while (s--) t /= 10.0;
			x = (x + t) * f;
			return *this;
		}
		Reader& operator >> (__float128 &x)
		{
			x = 0;
			__float128 t = 0;
			short f = 1, s = 0;
			char c = getchar();
			while ((c < '0' || c > '9') && c != '.') { if (c == '-') f *= -1; c = getchar(); }
			while (c >= '0' && c <= '9' && c != '.') x = x * 10 + (c ^ 48), c = getchar();
			if (c == '.') c = getchar();
			else { x *= f; return *this; }
			while (c >= '0' && c <= '9') t = t * 10 + (c ^ 48), s++, c = getchar();
			while (s--) t /= 10.0;
			x = (x + t) * f;
			return *this;
		}
		Reader& operator >> (char &c)
		{
			c = getchar();
			while (c == ' ' || c == '\n' || c == '\r') c = getchar();
			return *this;
		}
		Reader& operator >> (char *str)
		{
			int len = 0;
			char c = getchar();
			while (c == ' ' || c == '\n' || c == '\r') c = getchar();
			while (c != ' ' && c != '\n' && c != '\r') str[len++] = c, c = getchar();
			str[len] = '\0';
			return *this;
		}
		Reader& operator >> (string &str)
		{
			str.clear();
			char c = getchar();
			while (c == ' ' || c == '\n' || c == '\r') c = getchar();
			while (c != ' ' && c != '\n' && c != '\r') str.push_back(c), c = getchar();
			return *this;
		}
		Reader() {}
	} cin;
	const char endl = '\n';
	struct Writer
	{
		const int Setprecision = 6;
		typedef int mxdouble;
		template <typename T> Writer& operator << (T x)
		{
			if (x == 0) { putchar('0'); return *this; }
			if (x < 0) putchar('-'), x = -x;
			static short sta[40];
			short top = 0;
			while (x > 0) sta[++top] = x % 10, x /= 10;
			while (top > 0) putchar(sta[top] + '0'), top--;
			return *this;
		}
		Writer& operator << (double x)
		{
			if (x < 0) putchar('-'), x = -x;
			mxdouble _ = x;
			x -= (double)_;
			static short sta[40];
			short top = 0;
			while (_ > 0) sta[++top] = _ % 10, _ /= 10;
			if (top == 0) putchar('0');
			while (top > 0) putchar(sta[top] + '0'), top--;
			putchar('.');
			for (int i = 0; i < Setprecision; i++) x *= 10;
			_ = x;
			while (_ > 0) sta[++top] = _ % 10, _ /= 10;
			for (int i = 0; i < Setprecision - top; i++) putchar('0');
			while (top > 0) putchar(sta[top] + '0'), top--;
			return *this;
		}
		Writer& operator << (long double x)
		{
			if (x < 0) putchar('-'), x = -x;
			mxdouble _ = x;
			x -= (long double)_;
			static short sta[40];
			short top = 0;
			while (_ > 0) sta[++top] = _ % 10, _ /= 10;
			if (top == 0) putchar('0');
			while (top > 0) putchar(sta[top] + '0'), top--;
			putchar('.');
			for (int i = 0; i < Setprecision; i++) x *= 10;
			_ = x;
			while (_ > 0) sta[++top] = _ % 10, _ /= 10;
			for (int i = 0; i < Setprecision - top; i++) putchar('0');
			while (top > 0) putchar(sta[top] + '0'), top--;
			return *this;
		}
		Writer& operator << (__float128 x)
		{
			if (x < 0) putchar('-'), x = -x;
			mxdouble _ = x;
			x -= (__float128)_;
			static short sta[40];
			short top = 0;
			while (_ > 0) sta[++top] = _ % 10, _ /= 10;
			if (top == 0) putchar('0');
			while (top > 0) putchar(sta[top] + '0'), top--;
			putchar('.');
			for (int i = 0; i < Setprecision; i++) x *= 10;
			_ = x;
			while (_ > 0) sta[++top] = _ % 10, _ /= 10;
			for (int i = 0; i < Setprecision - top; i++) putchar('0');
			while (top > 0) putchar(sta[top] + '0'), top--;
			return *this;
		}
		Writer& operator << (char c) { putchar(c); return *this; }
		Writer& operator << (char *str)
		{
			int cur = 0;
			while (str[cur]) putchar(str[cur++]);
			return *this;
		}
		Writer& operator << (const char *str)
		{
			int cur = 0;
			while (str[cur]) putchar(str[cur++]);
			return *this;
		}
		Writer& operator << (string str)
		{
			int st = 0, ed = str.size();
			while (st < ed) putchar(str[st++]);
			return *this;
		}
		Writer() {}
	} cout;
}
using namespace Fastio;
#define cin Fastio::cin
#define cout Fastio::cout
#define endl Fastio::endl
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		int x;
		cin>>x;
		s+=x;
	}
	cout<<s;
	return 0;
}

有内味了

2 个赞

偶遇天生人机圣体,拼尽全力无法分辨

2 个赞

我是AI(

写大摸你写魔怔了)

看出来了

2 个赞

这是xyc大佬送我的慢读慢写。
支持int128,float128 double long double int long long

1 个赞

《慢读慢写》

支持的太多了
少一点会很快

1 个赞

下一步:写题解的时候故意仿照 AI 风格,代码故意仿照 AI,撤下自己的所有专栏,
然后比赛时仿照 AI 风,把自己变成棕名,
接着再仿照 AI 风跟别人聊天,
仿照 AI 风写题,然后变成实质性棕名,
再仿照 AI 风发wyy,把自己禁言,
最后发现你被封了,但你什么都没有做,
最后仿照 AI 风写个申诉,管理一怒之下把你永久封禁了

……