QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#600587 | #6562. First Last | Forever_Young | WA | 0ms | 3960kb | C++14 | 1.9kb | 2024-09-29 17:32:57 | 2024-09-29 17:32:58 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define data dataa
using LL=long long;
using ULL=unsigned long long;
using LD=long double;
char s[1010][20];
int g[4][4],n;
map<char,int>id;
bool check(int n,int a,int g[4][4])
{
bool res_x=0,res;
for (int i=1;i<=3;i++)
for (int j=1;j<=3;j++) printf("%d,%d = %d\n",i,j,g[i][j]);
int b=a%3+1,c=b%3+1;
if (g[a][b]>g[b][a]&&g[a][c]>g[c][a]){
if (g[b][c]<g[c][b]) swap(b,c);
} else
if (g[a][c]>g[c][a]) swap(b,c);
int A=g[a][b]-g[b][a],B=g[b][c]-g[c][b],C=g[c][a]-g[a][c];
if (A>0&&B>0&&C>0){
int t = min(A,min(B,C));
A-=t,B-=t,C-=t;
res_x^=t&1;
}
int AA=g[a][a]&1,BB=g[b][b]&1,CC=g[c][c]&1;
if (A>0&&B>0){
res = ((!AA&&!BB&&!CC)||(!AA&&BB))^res_x;
} else
if (A>0&&C<0){
res = ((!AA&BB)&&(!AA&(-CC)))^res_x;
}else
if (A>0){
res = ((!AA&BB))^res_x;
} else
res = (!AA)^res_x;
printf("%d %d %d %d %d %d = %d\n",A,B,C,AA,BB,CC,res);
// printf("%d\n",res);
return res;
}
int main()
{
scanf("%d",&n);
rep(i,n)scanf("%s",s[i]);
int ans=0;
rep(i,n)
{
memset(g,0,sizeof(g));
id.clear();
int cnt=0;
rep(j,n)
{
if(i==j)continue;
int len=strlen(s[j]);
char a=s[j][0],b=s[j][len-1];
int x,y;
if(id.count(a)>0)x=id[a];else id[a]=++cnt,x=cnt;
if(id.count(b)>0)y=id[b];else id[b]=++cnt,y=cnt;
g[x][y]++;
}
char a=s[i][strlen(s[i])-1];
int st;
if(id.count(a)>0)st=id[a];else id[a]=++cnt,st=cnt;
assert(cnt<=3);
printf("No %s\n",s[i]);
if(check(cnt,st,g))ans++;
}
printf("%d\n",ans);
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3960kb
input:
3 attic climb alpha
output:
No attic 1,1 = 0 1,2 = 1 1,3 = 0 2,1 = 0 2,2 = 0 2,3 = 0 3,1 = 0 3,2 = 0 3,3 = 1 1 0 0 0 0 1 = 0 No climb 1,1 = 1 1,2 = 1 1,3 = 0 2,1 = 0 2,2 = 0 2,3 = 0 3,1 = 0 3,2 = 0 3,3 = 0 0 1 0 0 1 0 = 1 No alpha 1,1 = 0 1,2 = 1 1,3 = 0 2,1 = 0 2,2 = 0 2,3 = 1 3,1 = 0 3,2 = 0 3,3 = 0 1 1 0 0 0 0 = 1 2
result:
wrong answer 1st lines differ - expected: '2', found: 'No attic'