2 条题解

题解与来源题共享。已有题解默认通过;新增或编辑后需由来源域管理员审核。待审核、驳回题解仅作者和审核管理员可见。来源域:system

  • -1
    @ 2025-6-14 16:37:15

    #include #include #include

    using namespace std; queue arr; int m; signed main() { cin >> m; while(m--) { string s; int x; cin >> s; if(s == "push") { cin >> x; arr.push(x); } else if(s == "pop") { if(arr.empty()) { continue; } else { arr.pop(); } } else if(s == "empty") { if(arr.empty()) { cout << "YES" << endl; } else { cout << "NO" << endl; } } else if(s == "query") { if(arr.empty()) { cout << "empty" << endl; } else { cout << arr.front() << endl; } } } return 0; }

信息

ID
57
时间
1000ms
内存
256MiB
难度
入门
标签
递交数
122
已通过
51
上传者