【乐子发言】Windows 和 Linux 到底有何不同
  • 板块灌水区
  • 楼主da_ke
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/9/16 21:24
  • 上次更新2024/9/16 21:25:24
查看原帖
【乐子发言】Windows 和 Linux 到底有何不同
766675
da_ke楼主2024/9/16 21:24

今天也算是震惊了。

#include <bits/stdc++.h>

#define i64 long long
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define fdn(i,r,l) for(int i=(r);i>=(l);i--)
#define pii pair<int,int>
using namespace std;

typedef long long ll;
typedef double db;
typedef __int128 i128;

ll f(string s)
{
    ll cnt=0,ans=0;
    for(auto i:s)
    {
        if(i=='X') cnt++;
        else ans+=cnt*(i-'0');
    }
    return ans;
}

bool cmp(string s1,string s2)
{
    return f(s1+s2)>f(s2+s1);
}

int main()
{
#ifndef ONLINE_JUDGE 
    freopen("in.in","r",stdin);
    freopen("out .out","w",stdout);
#endif
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int n;
    cin>>n;
    vector<string> s(n);
    rep(i,0,n-1) cin>>s[i];
    sort(s.begin(),s.end(),cmp);
    string o="";
    for(auto& i:s) o+=i;
    cout<<f(o)<<endl;
}

我有上面的代码,输入为:

10
X63X395XX
X2XX3X22X
13
3716XXX6
45X
X6XX
9238
281X92
1XX4X4XX6
54X9X711X1

Windows 下无论输入什么输出都是 1,而我断言这是 Windows 的 feature,用 AtCoder Custom Test,果真!

thus,这段代码为啥有 feature?

2024/9/16 21:24
加载中...