ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <algorithm>

#include <cstring>

#include <vector>

#include <queue>

#include <deque>

#include <cmath>

#include <map>

#include <set>

#define endl '\n'

#define db(a) cout << #a << "=" << (a) << endl;

#define x first

#define y second

using namespace std;



const int N = 2e5 + 10, M = 2e5 + 10, INF = 0x3f3f3f3f;



typedef long long ll;



typedef pair<int, int> PII;



int T;

ll a[N];



int main() {

	cin >> T;

	while(T --){

		int n, l, r;

		cin >> n >> l >> r;

		for(int i = 0; i < n; i ++) cin >> a[i];

		sort(a, a + n);

		int len = r - l + 1;

		ll ans = 0;

		for(int i = 0; i < len; i ++) ans += a[i];

		cout << ans << endl;

	}

    return 0;

}







Submission (verdict: Wrong answer on test 8):
#include <iostream>

#include <algorithm>

#include <cstring>

#include <vector>

#include <queue>

#include <deque>

#include <cmath>

#include <map>

#include <set>

#define endl '\n'

#define db(a) cout << #a << "=" << (a) << endl;

#define x first

#define y second

using namespace std;



const int N = 2e5 + 10, M = 2e5 + 10, INF = 0x3f3f3f3f;



typedef long long ll;



typedef pair<int, int> PII;



int T;

int a[N], b[N], c[N];



int main() {

	cin >> T;

	while(T --){

		int n, l, r;

		cin >> n >> l >> r;

		for(int i = 1; i <= n; i ++){

			cin >> a[i];

			b[i] = a[i];

			c[i] = a[i];

		} 

		sort(b + 1, b + r + 1);

		sort(c + l, c + n + 1);

		int len = r - l + 1;

		int s1 = 0, s2 = 0;

		for(int i = 1; i <= len; i ++) s1 += b[i];

		for(int i = l; i < l + len; i ++) s2 += c[i];

		int ans = min(s1, s2);

		cout << ans << endl;

	}

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 8):
#include <iostream>

#include <algorithm>

#include <cstring>

#include <vector>

#include <queue>

#include <deque>

#include <cmath>

#include <map>

#include <set>

#define endl '\n'

#define db(a) cout << #a << "=" << (a) << endl;

#define x first

#define y second

using namespace std;



const int N = 2e5 + 10, M = 2e5 + 10, INF = 0x3f3f3f3f;



typedef long long ll;



typedef pair<int, int> PII;



int T;

int a[N], b[N], c[N];



int main() {

	cin >> T;

	while(T --){

		int n, l, r;

		cin >> n >> l >> r;

		for(int i = 1; i <= n; i ++){

			cin >> a[i];

			b[i] = a[i];

			c[i] = a[i];

		} 

		sort(b + 1, b + r + 1);

		sort(c + l, c + n + 1);

		int len = r - l + 1;

		int s1 = 0, s2 = 0;

		for(int i = 1; i <= len; i ++) s1 += b[i];

		for(int i = l; i < l + len; i ++) s2 += c[i];

		int ans = min(s1, s2);

		cout << ans << endl;

	}

    return 0;

}







Submission (verdict: Wrong answer on test 8):
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#define endl '\n'
#define db(a) cout << #a << "=" << (a) << endl;
#define x first
#define y second
using namespace std;

const int N = 2e5 + 10, M = 2e5 + 10, INF = 0x3f3f3f3f;

typedef long long ll;

typedef pair<int, int> PII;

int T;
ll a[N], b[N], c[N];

int main() {
	cin >> T;
	while(T --){
		int n, l, r;
		cin >> n >> l >> r;
		for(int i = 1; i <= n; i ++){
			cin >> a[i];
			b[i] = a[i];
			c[i] = a[i];
		} 
		sort(b + 1, b + r + 1);
		sort(c + l, c + n + 1);
		int len = r - l + 1;
		ll s1 = 0, s2 = 0;
		for(int i = 1; i <= len; i ++) s1 += b[i];
		for(int i = l; i < l + len; i ++) s2 += c[i];
		int ans = min(s1, s2);
		cout << ans << endl;
	}
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <algorithm>

#include <cstring>

#include <vector>

#include <queue>

#include <deque>

#include <cmath>

#include <map>

#include <set>

#define endl '\n'

#define db(a) cout << #a << "=" << (a) << endl;

#define x first

#define y second

using namespace std;



const int N = 2e5 + 10, M = 2e5 + 10, INF = 0x3f3f3f3f;



typedef long long ll;



typedef pair<int, int> PII;



int T;

int a[N];



int main() {

	cin >> T;

	while(T --){

		int n, l, r;

		cin >> n >> l >> r;

		for(int i = 0; i < n; i ++) cin >> a[i];

		sort(a, a + n);

		int len = r - l + 1;

		ll ans = 0;

		for(int i = 0; i < len; i ++) ans += a[i];

		cout << ans << endl;

	}

    return 0;

}







Submission (verdict: Wrong answer on test 2):
#include <iostream>

#include <algorithm>

#include <cstring>

#include <vector>

#include <queue>

#include <deque>

#include <cmath>

#include <map>

#include <set>

#define endl '\n'

#define db(a) cout << #a << "=" << (a) << endl;

#define x first

#define y second

using namespace std;



const int N = 2e5 + 10, M = 2e5 + 10, INF = 0x3f3f3f3f;



typedef long long ll;



typedef pair<int, int> PII;



int T;

ll a[N];



int main() {

	cin >> T;

	while(T --){

		int n, l, r;

		cin >> n >> l >> r;

		for(int i = 0; i < n; i ++) cin >> a[i];

		sort(a, a + n);

		int len = r - l + 1;

		ll ans = 0;

		for(int i = 0; i < len; i ++) ans += a[i];

		cout << ans << endl;

	}

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#include "bits/stdc++.h"

using namespace std;

void solve()

{

    int n;

    cin>>n;

    vector<int> a(n);

    for(int &i:a) cin>>i;

    int j=0;

    for(int i=1;i<n;i++)

    {

        if(a[i-1]>a[i]) j=i;

    }

    if(j==0)

    {

        cout<<"YES"<<'\n';

        return ;

    }

    auto jian = [&](int l)

    {

        int minn=min(a[i],a[i+1]);

        a[i]-=minn;

        a[i+1]-=minn;

    }

    for(int i=0;i<j;i++)

    {

        jian(i);

    }

    if(is_sorted(a.begin(),a.end()))

    {

        cout<<"YES"<<"\n";

        return ;

    }

    else cout<<"NO"<<'\n';

}

int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int t;

    cin>>t;

    while(t--)

    {

        solve();

    }

    return 0;

}

Submission (verdict: Compilation error):
#include "bits/stdc++.h"

using namespace std;

void solve()

{

    int n;

    cin>>n;

    vector<int> a(n);

    for(int &i:a) cin>>i;

    int j=0;

    for(int i=1;i<n;i++)

    {

        if(a[i-1]>a[i]) j=i;

    }

    if(j==0)

    {

        cout<<"YES"<<'\n';

        return ;

    }

    auto jian = [&](int l)

    {

        int minn=min(a[l],a[l+1]);

        a[l]-=minn;

        a[l+1]-=minn;

    }

    for(int i=0;i<j;i++)

    {

        jian(i);

    }

    if(is_sorted(a.begin(),a.end()))

    {

        cout<<"YES"<<"\n";

        return ;

    }

    else cout<<"NO"<<'\n';

}

int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int t;

    cin>>t;

    while(t--)

    {

        solve();

    }

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include "bits/stdc++.h"

using namespace std;

void solve()

{

    int n;

    cin>>n;

    vector<int> a(n+1);

    for(int i=1;i<=n;i++) cin>>a[i];

    for(int i=2;i<=n-1;i++)

    {

        if(a[i]<a[i-1]&&a[i]>a[i+1])

        {

            cout<<"NO"<<'\n';

            return ;

        }

        else if(a[i]==a[i-1]&&a[i]>a[i+1])

        {

            if(i<=n-2&&a[i+1]==a[i+2]) continue;

            cout<<"NO"<<'\n';

            return ;

        }



    }

    cout<<"YES"<<"\n";

}

int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int t;

    cin>>t;

    while(t--)

    {

        solve();

    }

    return 0;

}

Submission (verdict: Wrong answer on test 2):
#include "bits/stdc++.h"

using namespace std;

void solve()

{

    int n;

    cin>>n;

    vector<int> a(n+1);

    for(int i=1;i<=n;i++) cin>>a[i];

    if(n<=2)

    {

        if(a[1]>a[2])

        {

            cout<<"NO"<<'\n';

            return ;

        }

    }

    for(int i=2;i<=n-1;i++)

    {

        if(a[i]<a[i-1]&&a[i]>a[i+1])

        {

            cout<<"NO"<<'\n';

            return ;

        }

        else if(a[i]==a[i-1]&&a[i]>a[i+1])

        {

            if(i<=n-2&&a[i+1]==a[i+2]) continue;

            cout<<"NO"<<'\n';

            return ;

        }



    }

    cout<<"YES"<<"\n";

}

int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int t;

    cin>>t;

    while(t--)

    {

        solve();

    }

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include "bits/stdc++.h"

using namespace std;

void solve()

{

    int n;

    cin>>n;

    vector<int> a(n+1);

    for(int i=1;i<=n;i++) cin>>a[i];

    for(int i=2;i<=n-1;i++)

    {

        if(a[i]<a[i-1]&&a[i]>a[i+1])

        {

            cout<<"NO"<<'\n';

            return ;

        }

        else if(a[i]==a[i-1]&&a[i]>a[i+1])

        {

            if(i<=n-2&&a[i+1]==a[i+2]) continue;

            cout<<"NO"<<'\n';

            return ;

        }



    }

    cout<<"YES"<<"\n";

}

int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int t;

    cin>>t;

    while(t--)

    {

        solve();

    }

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include "bits/stdc++.h"

using namespace std;

void solve()

{

    int n;

    cin>>n;

    vector<int> a(n+1);

    for(int i=1;i<=n;i++) cin>>a[i];

    if(n<=2)

    {

        if(a[1]>a[2])

        {

            cout<<"NO"<<'\n';

            return ;

        }

    }

    for(int i=2;i<=n-1;i++)

    {

        if(a[i]<a[i-1]&&a[i]>a[i+1])

        {

            cout<<"NO"<<'\n';

            return ;

        }

        else if(a[i]==a[i-1]&&a[i]>a[i+1])

        {

            if(i<=n-2&&a[i+1]==a[i+2]) continue;

            cout<<"NO"<<'\n';

            return ;

        }



    }

    cout<<"YES"<<"\n";

}

int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int t;

    cin>>t;

    while(t--)

    {

        solve();

    }

    return 0;

}

Submission (verdict: Compilation error):
#include "bits/stdc++.h"

using namespace std;

void solve()

{

    int n;

    cin>>n;

    vector<int> a(n);

    for(int &i:a) cin>>i;

    int j=0;

    for(int i=1;i<n;i++)

    {

        if(a[i-1]>a[i]) j=i;

    }

    if(j==0)

    {

        cout<<"YES"<<'\n';

        return ;

    }

    auto jian = [&](int l)

    {

        int minn=min(a[i],a[i+1]);

        a[i]-=minn;

        a[i+1]-=minn;

    }

    for(int i=0;i<j;i++)

    {

        jian(i);

    }

    if(is_sorted(a.begin(),a.end()))

    {

        cout<<"YES"<<"\n";

        return ;

    }

    else cout<<"NO"<<'\n';

}

int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int t;

    cin>>t;

    while(t--)

    {

        solve();

    }

    return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#include "bits/stdc++.h"

using namespace std;

void solve()

{

    int n;

    cin>>n;

    vector<int> a(n);

    for(int &i:a) cin>>i;

    int j=0;

    for(int i=1;i<n;i++)

    {

        if(a[i-1]>a[i]) j=i;

    }

    if(j==0)

    {

        cout<<"YES"<<'\n';

        return ;

    }

    auto jian = [&](int l)

    {

        int minn=min(a[l],a[l+1]);

        a[l]-=minn;

        a[l+1]-=minn;

    }

    for(int i=0;i<j;i++)

    {

        jian(i);

    }

    if(is_sorted(a.begin(),a.end()))

    {

        cout<<"YES"<<"\n";

        return ;

    }

    else cout<<"NO"<<'\n';

}

int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int t;

    cin>>t;

    while(t--)

    {

        solve();

    }

    return 0;

}

Submission (verdict: Accepted):
#include "bits/stdc++.h"

using namespace std;

void solve()

{

    int n;

    cin>>n;

    vector<int> a(n);

    for(int &i:a) cin>>i;

    int j=0;

    for(int i=1;i<n;i++)

    {

        if(a[i-1]>a[i]) j=i;

    }

    if(j==0)

    {

        cout<<"YES"<<'\n';

        return ;

    }

    auto jian = [&](int l)

    {

        int minn=min(a[l],a[l+1]);

        a[l]-=minn;

        a[l+1]-=minn;

    };

    for(int i=0;i<j;i++)

    {

        jian(i);

    }

    if(is_sorted(a.begin(),a.end()))

    {

        cout<<"YES"<<"\n";

        return ;

    }

    else cout<<"NO"<<'\n';

}

int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int t;

    cin>>t;

    while(t--)

    {

        solve();

    }

    return 0;

}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 6):
// #define first x
// #define second y
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int ll
typedef pair<ll, ll> pii;
typedef pair<double, int> pdi;
const int N = 2e6 + 10, mod = 998244353, inf = 0x3f3f3f3f;

string s;
void work(){
    cin >> s;

    int len = s.size();
    s = " " + s;

    for(int i = len;i >= 1;i--){

        for(int j = len;j >= 2;j--){
            if(s[j] == '0') continue;

            if(s[j] - 1 > s[j - 1]){
                s[j] -= 1;
                swap(s[j],s[j - 1]);
            }
        }
    }

    s.erase(s.begin());
    cout << s << "\n";
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int _;
    // _ = 1;
    cin >> _;

    while (_--)
    {
        work();
    }
    return 0;
}

Submission (verdict: Accepted):
// #define first x
// #define second y
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int ll
typedef pair<ll, ll> pii;
typedef pair<double, int> pdi;
const int N = 2e6 + 10, mod = 998244353, inf = 0x3f3f3f3f;

string s;
void work(){
    cin >> s;

    int len = s.size();
    
    for(int i = 1;i < len;i++){
        if(s[i] - s[i - 1] > 1){

            int j = i;
            while(j >= 1 && s[j] - s[j - 1] > 1){
                s[j]--;
                swap(s[j],s[j - 1]);
                --j;
            }
        }
    }

    cout << s << "\n";
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int _;
    // _ = 1;
    cin >> _;

    while (_--)
    {
        work();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
// #define first x
// #define second y
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int ll
typedef pair<ll, ll> pii;
typedef pair<double, int> pdi;
const int N = 2e6 + 10, mod = 998244353, inf = 0x3f3f3f3f;

string s;
void work(){
    cin >> s;

    int len = s.size();
    s = " " + s;

    // cout << len;
    for(int i = 1;i <= len;i++){

        int maxn = 0;
        int t = len;

        int flag = 0;
        if(i + 1 > len){
            break;
        }
        for(int j = len;j >= i + 1;j--){
            if(s[j] - (j - i) > s[i] && maxn < s[j] - (j - i)){
                maxn = s[j] - (j - i) - '0';
                t = j;
                flag = 1;
            }
        }
        

        if(flag){
            s[t] = s[t]- (t - i);
            swap(s[t],s[i]);
        }
    }
    // cout << 1 << "\n";
    s.erase(s.begin());

    cout << s << "\n";
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int _;
    // _ = 1;
    cin >> _;

    while (_--)
    {
        work();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 1):
// #define first x
// #define second y
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int ll
typedef pair<ll, ll> pii;
typedef pair<double, int> pdi;
const int N = 2e6 + 10, mod = 998244353, inf = 0x3f3f3f3f;

string s;
void work(){
    cin >> s;

    int len = s.size();
    s = " " + s;

    // cout << len;
    for(int i = 1;i <= len;i++){

        if(s[0] == '0') continue;
        int maxn = 0;
        int t = len;

        int flag = 0;
        if(i + 1 > len){
            break;
        }
        for(int j = len;j >= i + 1;j--){
            if(s[j] - (j - i) > s[i] && maxn < s[j] - (j - i)){
                maxn = s[j] - (j - i) - '0';
                t = j;
                flag = 1;
            }
        }
        

        if(flag){
            s[t] = s[t]- (t - i);
            swap(s[t],s[i]);
        }
    }
    // cout << 1 << "\n";
    s.erase(s.begin());

    cout << s << "\n";
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int _;
    // _ = 1;
    cin >> _;

    while (_--)
    {
        work();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
// #define first x
// #define second y
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int ll
typedef pair<ll, ll> pii;
typedef pair<double, int> pdi;
const int N = 2e6 + 10, mod = 998244353, inf = 0x3f3f3f3f;

string s;
void work(){
    cin >> s;

    int len = s.size();
    s = " " + s;

    // cout << len;
    for(int i = 1;i <= len;i++){

        if(s[0] == '0') continue;
        int maxn = 0;
        int t = len;

        int flag = 0;
        if(i + 1 > len){
            break;
        }
        for(int j = len;j >= i + 1;j--){
            if(s[j] - (j - i) > s[i] && maxn < s[j] - (j - i)){
                maxn = s[j] - (j - i) - '0';
                t = j;
                flag = 1;
            }
        }
        

        if(flag){
            s[t] = s[t]- (t - i);
            swap(s[t],s[i]);
        }
    }
    // cout << 1 << "\n";
    s.erase(s.begin());

    cout << s << "\n";
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int _;
    // _ = 1;
    cin >> _;

    while (_--)
    {
        work();
    }
    return 0;
}

Submission (verdict: Time limit exceeded on test 6):
// #define first x
// #define second y
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int ll
typedef pair<ll, ll> pii;
typedef pair<double, int> pdi;
const int N = 2e6 + 10, mod = 998244353, inf = 0x3f3f3f3f;

string s;
void work(){
    cin >> s;

    int len = s.size();
    s = " " + s;

    for(int i = len;i >= 1;i--){

        for(int j = len;j >= 2;j--){
            if(s[j] == '0') continue;

            if(s[j] - 1 > s[j - 1]){
                s[j] -= 1;
                swap(s[j],s[j - 1]);
            }
        }
    }

    s.erase(s.begin());
    cout << s << "\n";
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int _;
    // _ = 1;
    cin >> _;

    while (_--)
    {
        work();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
// #define first x
// #define second y
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int ll
typedef pair<ll, ll> pii;
typedef pair<double, int> pdi;
const int N = 2e6 + 10, mod = 998244353, inf = 0x3f3f3f3f;

string s;
void work(){
    cin >> s;

    int len = s.size();
    s = " " + s;

    // cout << len;
    for(int i = 1;i <= len;i++){

        int maxn = 0;
        int t = len;

        int flag = 0;
        if(i + 1 > len){
            break;
        }
        for(int j = len;j >= i + 1;j--){
            if(s[j] - (j - i) > s[i] && maxn < s[j] - (j - i)){
                maxn = s[j] - (j - i) - '0';
                t = j;
                flag = 1;
            }
        }
        

        if(flag){
            s[t] = s[t]- (t - i);
            swap(s[t],s[i]);
        }
    }
    // cout << 1 << "\n";
    s.erase(s.begin());

    cout << s << "\n";
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int _;
    // _ = 1;
    cin >> _;

    while (_--)
    {
        work();
    }
    return 0;
}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>

using namespace std;



int main()

{

    int t;

    cin >> t;



    while(t --)

    {

        int n;

        string str;

        cin >> n >> str;

        int p = n, s = 0;

        for(int i = 0; i < n; i ++)

        {

            if(str[i] == 'p') p = min(p, i);

            if(str[i] == 's') s = max(s, i); 

        }

        if(p < s) cout << "NO" << "\n";

    else if(str[0] == '.' && str[n - 1] == '.' && p != n && s != 0) cout << "NO" << "\n";

        else cout << "YES" << "\n";



    }

}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>

using namespace std;



int main()

{

    int t;

    cin >> t;



    while(t --)

    {

        int n;

        string str;

        cin >> n >> str;

        int p = n, s = -1;

        for(int i = 0; i < n; i ++)

        {

            if(str[i] == 'p') p = min(p, i);

            if(str[i] == 's') s = max(s, i); 

        }

        if(p < s) cout << "NO" << "\n";

    else if(str[0] == '.' && str[n - 1] == '.' && p != n && s != -1) cout << "NO" << "\n";

        else cout << "YES" << "\n";



    }

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>

using namespace std;



int main()

{

    int t;

    cin >> t;



    while(t --)

    {

        int n;

        string str;

        cin >> n >> str;

        int p = n, s = 0;

        for(int i = 0; i < n; i ++)

        {

            if(str[i] == 'p') p = min(p, i);

            if(str[i] == 's') s = max(s, i); 

        }

        if(p < s) cout << "NO" << "\n";

        else if(str[0] == '.' && str[n - 1] == '.' && p != n && s != 0) cout << "NO" << "\n";

        else cout << "YES" << "\n";



    }

}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>

using namespace std;



int main()

{

    int t;

    cin >> t;



    while(t --)

    {

        int n;

        string str;

        cin >> n >> str;

        int p = n, s = 0;

        for(int i = 0; i < n; i ++)

        {

            if(str[i] == 'p') p = min(p, i);

            if(str[i] == 's') s = max(s, i); 

        }

        if(p < s) cout << "NO" << "\n";

    else if(str[0] == '.' && str[n - 1] == '.' && p != n && s != 0) cout << "NO" << "\n";

        else cout << "YES" << "\n";



    }

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>

using namespace std;



int main()

{

    int t;

    cin >> t;



    while(t --)

    {

        int n;

        string str;

        cin >> n >> str;

        int p = 0, s = 0;

        for(int i = 0; i < n; i ++)

        {

            if(str[i] == 'p') p ++;

            if(str[i] == 's') s ++; 

        }

        if(p >= 1 && s >= 1 && str[n - 1] != 'p')

            cout << "NO" << "\n";

        else cout << "YES" << "\n";

    }

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>

using namespace std;



int main()

{

    int t;

    cin >> t;



    while(t --)

    {

        int n;

        string str;

        cin >> n >> str;

        int p = n, s = -1;

        for(int i = 0; i < n; i ++)

        {

            if(str[i] == 'p') p = min(p, i);

            if(str[i] == 's') s = max(s, i); 

        }

        if(p < s) cout << "NO" << "\n";

    else if(str[0] == '.' && str[n - 1] == '.' && p != n && s != -1) cout << "NO" << "\n";

        else cout << "YES" << "\n";



    }

}

Submission (verdict: Accepted):
#include<bits/stdc++.h>

using namespace std;



int main()

{

    int t;

    cin >> t;



    while(t --)

    {

        int n;

        string str;

        cin >> n >> str;

        int p = n, s = -1;

        for(int i = 0; i < n; i ++)

        {

            if(str[i] == 'p') p = min(p, i);

            if(str[i] == 's') s = max(s, i); 

        }

        if(p < s) cout << "NO" << "\n";

    else if(s == 0 || s == -1 || p == n - 1 || p == n) cout << "YES" << "\n";

        else cout << "NO" << "\n";



    }

}