QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#152630#6568. Space AlignmentBUET_POISSON#WA 1ms3660kbC++201.5kb2023-08-28 15:32:542023-08-28 15:32:57

Judging History

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

  • [2023-08-28 15:32:57]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3660kb
  • [2023-08-28 15:32:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long

const int M = 100006;
const int N = 106;

string grid[N];
int level[N],scount[N],tcount[N];
signed main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>grid[i];
    }
    int lvl = 0;
    for(int i=0;i<n;i++){
        int s,t;
        for(int j=0;j<grid[i].size();j++){

            if( grid[i][j] == 's' ) scount[i]++;
            if( grid[i][j] == 't' ) tcount[i]++;
            if( grid[i][j] == '{' ) {
                level[i] = lvl;
                lvl++;
            }
            if( grid[i][j] == '}' ) {
                lvl--;
                level[i] = lvl;
            }
        }
        //cout<<level[i]<<endl;
    }
    for(int i=0;i<n;i++){
        if( level[i] == 0 and (tcount[i]+scount[i]) ){
            cout<<-1<<endl;
            return 0;
        }
    }
    for(int i=1;i<N;i++){
        int k = -1;
        bool pos = true;
        for(int j=0;j<n;j++){
            if( level[j] == 0 ) continue;
            int len = tcount[j]*i + scount[j]; 
            if( len%level[j] != 0 ) {
                pos = false;
                break;
            }
            int temp = len/level[j];
           // cout<<level[j]<<" "<<len<<" "<<temp<<endl;
            if( temp != i ) pos = false;
        }

        if( pos ){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}

/*
10
{
ss{
sts{
tt}
t}
t{
ss}
}
{
}
*/

詳細信息

Test #1:

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

input:

10
{
ss{
sts{
tt}
t}
t{
ss}
}
{
}

output:

2

result:

ok single line: '2'

Test #2:

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

input:

2
{
}

output:

1

result:

ok single line: '1'

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3660kb

input:

4
{
ss{
ss}
}

output:

2

result:

wrong answer 1st lines differ - expected: '1', found: '2'