提交记录 20163


用户 题目 状态 得分 用时 内存 语言 代码长度
Yuina2008 noip17b. 【NOIP2017】时间复杂度 Accepted 100 164.63 us 36 KB C++14 3.05 KB
提交时间 评测时间
2023-09-15 21:12:53 2023-09-15 21:12:56
// P3952 [NOIP2017 提高组] 时间复杂度
// 125 MB 1000 ms

#include <bits/stdc++.h>

#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define mst(a, k) memset(a, k, sizeof a)
#define minv(a, b) a = min(a, b)
#define maxv(a, b) a = max(a, b)

#define put(x) printf("%d\n",x)
#define putl(x) printf("%lld\n",x)
#define mts() int t; scanf("%d", &t); while (t--) cout << ans[solve()] << '\n'

#define inf 0x3f3f3f3f
#define infl ((ll)1e18)

using namespace std;
using db = double;
using ll = long long;
using ull = unsigned long long;

int read(char* s) {
    int x = 0, f = 0, c = 1;
    for (; !isdigit(s[c]); ++c) f |= s[c] == 'n';
    for (; isdigit(s[c]); ++c) x = x * 10 + s[c] - 48;
    return x = f ? x : -x;
}

void read(string& s1, string& s2, string S) {
    int pos;
    for (pos = 4; pos <= (int)S.size() - 1 && S[pos] != ' '; ++pos) s1 += S[pos];
    // fprintf(stderr, "%d\n", pos);
    for (; pos <= (int)S.size() - 1 && S[pos] == ' '; ++pos);
    for (; pos <= (int)S.size() - 1 && S[pos] != ' '; ++pos) s2 += S[pos];
}

string ans[3] = { "Yes", "No", "ERR" };

int n, O;
int w[200], c[200];
int solve() { // t: 10  L: 100
    char s[20];
    scanf("%d %s", &n, s + 1);
    O = read(s);
    // fprintf(stderr, "%d %s %d\n", n, s + 1, O);
    
    getchar(); int sts = 0, f1 = 0, f2 = 0, f2_old = 0, f3 = 0;
    // f1: repeated value
    // f3: F i a b(a <=> b)
    string S; char val[107]; int top = 0;
    rep (i, 1, n) {
        getline(cin, S);
        // S[0] == 'F' ? ++sts : --sts;
        f2_old = maxv(f2_old, f2);
        if (sts == 0) f2 = 0, f3 = 0, top = 0;
        if (S[0] == 'F') {
            ++sts;
            w[sts] = w[sts-1];
            c[sts] = 0;
			rep (j, 1, top) if (S[2] == val[j]) f1 = 1;
            if (!f1) val[++top] = S[2];
            else {
                rep (j, i + 1, n) getline(cin, S);
                break;
            }
            string s1 = "", s2 = "";
            read(s1, s2, S);
            // cerr << '#' << i << ' ' << (s1 == "n") << ' ' << (s2 == "n") << '\n';
            if (s1 != "n" && s2 != "n") {
                int a1, a2;
                stringstream ss;
                ss << s1, ss >> a1, ss.clear(); ss << s2, ss >> a2;
                // cerr << '#' << i << ' ' << s1 << ' ' << s2 << '\n';
                // fprintf(stderr, "#%d a1 = %d a2 = %d\n\n", i, a1, a2);
                if (a1 > a2) w[sts]= 1;
            } else if (!w[sts]) {
                if (s1 == "n" && s2 != "n") w[sts] = 1;
                else if (s1 != "n" && s2 == "n") ++f2,c[sts]=1;
            }
            // fprintf(stderr, "#%d f3 = %d\n", i, f3);
        } else {
            f2 -= c[sts];
			--sts, --top;
            if(sts < 0) {
                f1=1;
                rep(j, i + 1, n) getline(cin, S);
                break;
            }
        }
    }
    
    maxv(f2, f2_old);
    if (f2 == 0) f2 = -1;
    // fprintf(stderr, "%d ", sts);
    // fprintf(stderr, "f2 = %d, O = %d\n", f2, O);
    if (sts || f1) return 2;
    if (f2 == O) return 0; else return 1;
}

int main() {
    mts();
    
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #144.94 us36 KBAcceptedScore: 10

Testcase #250.65 us36 KBAcceptedScore: 10

Testcase #367.92 us36 KBAcceptedScore: 10

Testcase #482.29 us36 KBAcceptedScore: 10

Testcase #569.22 us36 KBAcceptedScore: 10

Testcase #659.53 us36 KBAcceptedScore: 10

Testcase #7100.91 us36 KBAcceptedScore: 10

Testcase #8103.62 us36 KBAcceptedScore: 10

Testcase #9104.16 us36 KBAcceptedScore: 10

Testcase #10164.63 us36 KBAcceptedScore: 10


Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:15:31 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠