社区讨论
NOIP T1 爆零求助
学术版参与者 4已保存回复 7
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 7 条
- 当前快照
- 1 份
- 快照标识符
- @lp4u30te
- 此快照首次捕获于
- 2023/11/19 10:03 2 年前
- 此快照最后确认于
- 2023/11/19 11:39 2 年前
rt,T1爆零了QAQ
场上四个样例都过了,大样例用时也差不多卡在1s上下
有没有可能是linux环境和win环境的差异导致的?不是很会linux,求大佬帮忙看看orz
CPP#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 3010;
int n,m;
char w[N][N];
string w1[N];
string w2[N];
int cnt['z'];
struct node
{
int id;
string s;
};
node q[N];
int read()
{
int s = 0,t = 1;
char ch = getchar();
while(ch<'0'||ch>'9')
{
if(ch == '-') t = -1;
ch = getchar();
}
while(ch>='0'&&ch<='9')
{
s = s*10+ch-'0';
ch = getchar();
}
return s*t;
}
char read_c()
{
char ch = getchar();
while(ch<'a'||ch>'z') ch = getchar();
return ch;
}
bool cmp(node x,node y)
{
return x.s < y.s;
}
int main()
{
freopen("dict.in","r",stdin);
freopen("dict.out","w",stdout);
n = read(),m = read();
// for(int i = 1;i<=n;i++)
// {
// cin>>w[i];
// string t1 = "",t2 = "";
// string t = "a";
// for(int j = 0;j<(int)w[i].size();j++)
// {
// cnt[w[i][j]]++;
// }
// for(int j = 'a';j<='z';j++)
// {
// while(cnt[j]) t[0]=j,t1+=t,t2 = t+t2,cnt[j]--;
// }
// w1[i] = t1;
// w2[i] = t2;
// q[i] = {i,w2[i]};
// }
for(int i = 1;i<=n;i++)
{
for(int j = 1;j<=m;j++)
{
w[i][j] = read_c();
cnt[w[i][j]]++;
}
string t1 = "",t2 = "";
string t = "a";
for(int j = 'a';j<='z';j++)
{
while(cnt[j]) t[0]=j,t1+=t,t2 = t+t2,cnt[j]--;
}
w1[i] = t1;
w2[i] = t2;
q[i] = {i,w2[i]};
}
sort(q+1,q+1+n,cmp);
for(int i = 1;i<=n;i++)
{
bool flag = 1;
for(int j = 1;j<=n;j++)
{
if(i==q[j].id) continue;
flag = (w1[i] < q[j].s);
break;
}
if(flag) printf("1");
else printf("0");
}
return 0;
}
回复
共 7 条回复,欢迎继续交流。
正在加载回复...