首页 > 括号的匹配
头像 hujiao
发表于 2025-12-26 08:59:00
真是杂鱼呢~怎么这题都不会写阿❤。作为栈专栏的最后一题只要做了前一题就知道这题怎么写吧,这题最优解应该是 栈 + 嵌套顺序校验做法上如果是左括号就压栈,如果是右括号就判断是否 栈空 和 是否对应了左括号 如果不是栈空且对应了就出栈。但是这题要求了括号大小顺序也必须遵循,而这四个括号的左括号(只压栈左 展开全文
头像 小狐今天睡大觉
发表于 2025-12-14 02:42:44
#include <iostream> #include <map> #include <stack> using namespace std; int main() { int a; cin >> a; map<cha 展开全文
头像 Pek
发表于 2026-01-25 13:02:45
不会用map建立检查顺序,就直接简单粗暴写逻辑检验 #include <bits/stdc++.h> using namespace std; #define inf 0x3f3f3f3f #define int long long /* run this program using 展开全文
头像 Bdewiu
发表于 2025-12-09 10:41:15
#include <bits/stdc++.h> using namespace std; using ll = long long int; using ld = long double; using PII=pair<ll,ll>; using PIII=pair< 展开全文
头像 自由的风0450
发表于 2025-11-15 21:52:35
#include <iostream> #include <string> #include <stack> using namespace std; int getPriority(char c) { switch (c) { case 展开全文
头像 Sau_Hanson
发表于 2026-02-08 13:53:53
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin>>s; stack<char>t; for(int i=0;i<s.size 展开全文
头像 游云吞鲸
发表于 2026-01-20 09:34:25
#include <bits/stdc++.h> using namespace std; bool isvalid(const string & );//引用传递,无需拷贝 int main() { int T;cin>>T; while(T--& 展开全文
头像 牛客用户098471297
发表于 2025-11-28 11:40:32
#include<bits/stdc++.h> using namespace std; #define int long long #define endl '\n' #define quick ios::sync_with_stdio(false);cin.tie(0);cout.t 展开全文
头像 Drink0318
发表于 2025-12-10 10:49:37
import sys n = int(input()) data = iter(sys.stdin.read().splitlines()) dic ={"{":"}","[":"]","(":&qu 展开全文
头像 哈基图
发表于 2026-01-29 20:30:23
#include<bits/stdc++.h> #include<unordered_map> using namespace std; int main(){ int T; cin>>T; while(T--){ unor 展开全文

等你来战

查看全部