2 条题解

  • 3
    @ 2021-8-7 21:01:04

    C++ :

    #include <iostream>
    #include <algorithm>
    #include <vector>
    #include <cstring>
    using namespace std;
    
    string dfs(string a,int &x){
    	vector<string> v;
    	x++;
    	while(a[x]=='0') v.push_back(dfs(a,x));
    	x++;
    	sort(v.begin(),v.end());
    	string ans="0";
    	for(auto it:v) ans+=it;
    	ans+="1";
    	return ans;
    }
    
    int main()
    {
    	int t;
    	cin>>t;
    	while(t--){
    		string a,b;
    		cin>>a>>b;
    		a="0"+a+"1";
    		b="0"+b+"1";
    		int au=0,bu=0; 
    		if(dfs(a,au)==dfs(b,bu)){
    			cout<<"same"<<endl;
    		}else{
    			cout<<"different"<<endl;
    		}
    	}
    	return 0;
    }
    
    • 0
      @ 2024-9-24 16:12:12

      #include <iostream> #include <algorithm> #include <vector> #include <cstring> using namespace std;

      string dfs(string a,int &x){ vector<string> v; x++; while(a[x]=='0') v.push_back(dfs(a,x)); x++; sort(v.begin(),v.end()); string ans="0"; for(auto it:v) ans+=it; ans+="1"; return ans; }

      int main() { int t; cin>>t; while(t--){ string a,b; cin>>a>>b; a="0"+a+"1"; b="0"+b+"1"; int au=0,bu=0; if(dfs(a,au)==dfs(b,bu)){ cout<<"same"<<endl; }else{ cout<<"different"<<endl; } } return 0; }

      • 1

      信息

      ID
      68
      时间
      1000ms
      内存
      128MiB
      难度
      1
      标签
      递交数
      47
      已通过
      40
      上传者