QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#415597#6568. Space Alignmentngpin04#WA 1ms3868kbC++141.6kb2024-05-21 04:04:502024-05-21 04:04:50

Judging History

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

  • [2024-05-21 04:04:50]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3868kb
  • [2024-05-21 04:04:50]
  • 提交

answer

#include <bits/stdc++.h>
#define fi first 
#define se second
#define mp make_pair
#define bit(n) (1LL << (n))
#define getbit(x, i) (((x) >> (i)) & 1)
#define ii pair <int, int>
#define ALL(x) x.begin(), x.end()
#define long long long
using namespace std;
const int oo = 1e9;
const long ooo = 1e18;


vector<ii> vec[501];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;
    int depth = 0;
    for(int i = 0; i < n; i++)
    {
        int s = 0;
        int t = 0;
        string str; cin >> str;
        for(char c : str)
        {
            s += (c == 's');
            t += (c == 't');
        }

        if(str.back() == '}') depth--;

        vec[depth].push_back({s,t});
        
        if(str.back() == '{') depth++;
        
    }
    for(int i = 0; i <= 2000; i++)
    {
        bool bol = 1;
        for(auto it : vec[0])
        {
            int val = it.fi+it.se*i;
            // cout << "0 " << val << '\n';
            if(val) bol = 0;
        }
        if(!bol) continue;

        set<int> st;
        for(int j = 1; j <= 100; j++)
        {
            for(auto it : vec[j])
            {
                int val = it.fi+it.se*i;
                // cout << i << " " << j << " " << val << '\n';
                if(val == 0) bol = 0;
                if(val%j != 0) bol = 0;
                st.insert(val/j);
            }
        }
        if(!bol) continue;
        
        if(st.size() <= 1)
        {
            cout << i << "\n";
            return 0;
        }
    }
    cout << "-1\n"; 

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

2

result:

ok single line: '2'

Test #2:

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

input:

2
{
}

output:

0

result:

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