QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#707347 | #6562. First Last | ucup-team902# | WA | 0ms | 3808kb | C++17 | 1.3kb | 2024-11-03 15:35:50 | 2024-11-03 15:35:50 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define fi first
#define se second
#define bg begin
#define gc getchar
inline int read(){
char ch=gc();
int res=0;bool f=1;
while(!isdigit(ch))f^=ch=='-',ch=gc();
while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
return f?res:-res;
}
template<typename tp>inline void chemx(tp &a,tp b){(a<b)?(a=b):0;}
template<typename tp>inline void chemn(tp &a,tp b){(a>b)?(a=b):0;}
int id[30],m,n;
int cnt[3][3];
int now[3][3];
bool dfs(int x){
int ok=1;
for(int i=0;i<3;i++)if(now[x][i]){
now[x][i]--;
ok&=dfs(i);
}
return ok^1;
}
int main(){
#ifdef Stargazer
freopen("1.in","r",stdin);
#endif
cin>>n;
for(int i=1;i<=n;i++){
string s;cin>>s;int l=s.length();
int xx=s[0]-'a',yy=s[l-1]-'a';
if(!id[xx])id[xx]=m++;
if(!id[yy])id[yy]=m++;
cnt[xx][yy]++;
}
int ans=0;
for(int x=0;x<3;x++)
for(int y=0;y<3;y++)if(cnt[x][y]){
memcpy(now,cnt,sizeof(cnt));
now[x][y]--;
for(int i=0;i<3;i++)now[i][i]&=1;
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)if(i!=j){
int t=min(now[i][j],now[j][i]);
now[i][j]-=t,now[j][i]-=t;
}
if(!dfs(y))ans+=cnt[x][y];
}
cout<<ans<<'\n';
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3804kb
input:
3 attic climb alpha
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3496kb
input:
22 agora alpha antic aorta apnea arena aroma attic basic blurb china circa civic climb cobra cocoa comic comma conic crumb cubic cynic
output:
6
result:
ok single line: '6'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
3 ccabaabbba acbbbacccb ccccccacba
output:
1
result:
ok single line: '1'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3808kb
input:
11 mraa myga vtwm mala vvgm atvv vusm mznv avea atfv amgv
output:
1
result:
wrong answer 1st lines differ - expected: '7', found: '1'