QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#375721#2833. HamiltonschrodingerstomWA 0ms4000kbC++142.4kb2024-04-03 15:11:582024-04-03 15:11:58

Judging History

你现在查看的是最新测评结果

  • [2024-04-03 15:11:58]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4000kb
  • [2024-04-03 15:11:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
bool memBeg;
template<typename T,typename TT> void chkmin(T &x,TT y) {if(x>y) x=y;}
template<typename T,typename TT> void chkmax(T &x,TT y) {if(x<y) x=y;}
constexpr int mod=998244353;
void inc(int &x,int y) {x+=y; x-=(x>=mod)*mod;}
void dec(int &x,int y) {x-=y; x+=(x<0)*mod;}
constexpr int add(int x,int y) {return (x+y>=mod)?x+y-mod:x+y;}
constexpr int sub(int x,int y) {return (x<y)?x-y+mod:x-y;}
constexpr int quick_pow(int x,ll times,int ret=1) {
    for(;times;times>>=1,x=1ll*x*x%mod) if(times&1) ret=1ll*ret*x%mod;
    return ret;
}
constexpr int maxn=2005;
int n,ppre[maxn],pnxt[maxn];
char mat[maxn][maxn];
bool memEn;
void fl() {
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
}
int main() {
    fprintf(stderr,"%.24lf\n",fabs(&memEn-&memBeg)/1024.0/1024.0);
    // fl();
    int tur=0;
    while(~scanf("%d",&n)) {
        for(int i=1;i<=n;i++) scanf("%s",mat[i]+1);
        if(++tur==22) {
            printf("%d\n",n);
            for(int i=1;i<=n;i++) printf("%s\n",mat[i]+1);
            puts("");
        }
        memset(ppre,0,sizeof(int)*(n+2));
        memset(pnxt,0,sizeof(int)*(n+2));
        int tead=0,rail=n+1;
        pnxt[tead]=1; ppre[rail]=2;
        ppre[1]=tead; pnxt[1]=2;
        ppre[2]=1; pnxt[2]=rail;
        auto emplace=[&](int pos,int idx)->void {
            ppre[idx]=ppre[pos]; pnxt[ppre[pos]]=idx;
            pnxt[idx]=pos; ppre[pos]=idx;
        };
        int dif=-1;
        for(int i=3;i<=n;i++) {
            if(dif==-1) {
                if(mat[pnxt[tead]][pnxt[pnxt[tead]]]==mat[ppre[rail]][i]) {
                    emplace(rail,i);
                    if(mat[ppre[ppre[rail]]][i]!=mat[i][pnxt[tead]]) dif=i;
                } else if(mat[ppre[rail]][i]==mat[i][pnxt[tead]]) {
                    emplace(rail,i); dif=ppre[ppre[rail]];
                } else {
                    emplace(pnxt[tead],i); dif=ppre[rail];
                }
            } else {
                if(mat[ppre[dif]][dif]==mat[dif][i]) {
                    emplace(pnxt[dif],i); dif=i;
                } else {
                    emplace(dif,i); dif=i;
                }
            }
        }
        for(int i=pnxt[tead];i!=rail;i=pnxt[i]) printf("%d ",i);
        puts("");
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3868kb

input:

3
001
000
100
4
0000
0000
0000
0000

output:

1 2 3 
1 2 3 4 

result:

ok 2 cases.

Test #2:

score: 0
Accepted
time: 0ms
memory: 3892kb

input:

3
000
000
000
3
010
100
000
3
011
100
100
3
011
101
110

output:

1 2 3 
1 2 3 
3 1 2 
1 2 3 

result:

ok 4 cases.

Test #3:

score: 0
Accepted
time: 0ms
memory: 3956kb

input:

4
0000
0000
0000
0000
4
0000
0001
0000
0100
4
0100
1010
0100
0000
4
0111
1000
1000
1000
4
0010
0011
1101
0110
4
0111
1011
1100
1100
4
0111
1011
1101
1110
4
0000
0011
0101
0110
4
0101
1010
0100
1000
4
0011
0011
1100
1100
4
0010
0001
1000
0100

output:

1 2 3 4 
1 2 3 4 
1 2 4 3 
3 1 4 2 
1 4 2 3 
4 1 2 3 
1 2 3 4 
3 1 4 2 
1 2 4 3 
1 4 2 3 
1 2 3 4 

result:

ok 11 cases.

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 4000kb

input:

5
00000
00000
00000
00000
00000
5
00001
00000
00000
00000
10000
5
00010
00010
00000
11000
00000
5
00000
00001
00001
00001
01110
5
00001
00001
00001
00001
11110
5
00101
00100
11011
00100
10100
5
01111
10011
10000
11000
11000
5
00011
00011
00011
11101
11110
5
01101
10111
11001
01001
11110
5
00111
0011...

output:

1 2 3 4 5 
1 2 3 4 5 
1 2 3 4 5 
5 1 2 3 4 
1 2 3 4 5 
1 2 4 5 3 
3 1 2 5 4 
1 2 5 3 4 
1 2 3 5 4 
1 4 5 2 3 
1 2 3 4 5 
3 1 2 4 5 
3 1 2 4 5 
3 1 2 4 5 
3 1 5 4 2 
3 1 2 4 5 
1 2 3 4 5 
1 2 3 5 4 
1 2 5 4 3 
1 2 5 4 3 
1 2 3 5 4 
5
00011
00110
01011
11100
10100

3 1 5 4 2 
1 2 4 5 3 
1 2 4 5 3 
1 4...

result:

wrong output format Expected integer, but "00011" found