QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#94941#6128. Flippy Sequence2000805113#Compile Error//C++17965b2023-04-08 13:47:282023-04-08 13:47:31

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-08 13:47:31]
  • 评测
  • [2023-04-08 13:47:28]
  • 提交

answer

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

ll n;
string s1, s2;

using ll = long long;
using pll = pair<ll,ll>;
vector<pll> ve;

void solve() {
    ve.clear();
    cin >> n;
    cin >> s1 >> s2;
    for(int i = 0; i < n; i++){
        if(s1[i] != s2[i]){
            int j = i;
            while(j < n && s1[j] != s2[j]){
                j++;
            }
            ve.push_back({i, j});
            i = j;
        }
    }

    if(ve.size() == 0){
        cout << n * (n - 1) / 2 << '\n';
    }else if(ve.size() == 1){
        auto [l, r] = ve[0];
        cout << 2 * ((l) + (n - 1 - r) + (r - l)) << '\n';
    }else if(ve.size() == 2){
        auto [l1, r1] = ve[0];
        auto [l2, r2] = ve[1];
        cout << 6 << '\n';
    }else{
        cout << 0 << '\n';
    }
}
int main() {
    ios :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> T;
    while(T--) solve();
    return 0;
}

Details

answer.code:5:1: error: ‘ll’ does not name a type
    5 | ll n;
      | ^~
answer.code: In function ‘void solve()’:
answer.code:14:12: error: ‘n’ was not declared in this scope; did you mean ‘yn’?
   14 |     cin >> n;
      |            ^
      |            yn