2 条题解

  • 0
    @ 2025-11-28 19:42:44

    贪心

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int n;
    	cin>>n;
    	string str;
    	vector<bool>day(n,0);
    	vector<bool>night(n,0);
    	string s1,s2;
    	cin>>s1>>s2;
    	int h=0;
    	for(int i=0;i<n;i++){
    		if(s1[i]=='N'&&s2[i]=='N')continue;
    		if(s1[i]=='Y'&&s2[i]=='N')h+=2;
    		if(s1[i]=='N'&&s2[i]=='Y')h+=2;
    		if(s1[i]=='Y'&&s2[i]=='Y')h+=3;
    	}
    	cout<<h;
    }
    
    • 0
      @ 2025-11-28 0:36:14

      通过位运算避开模拟


      t=read_();gc();
      for(int i=0;i<t;i++){
         arr[i]=gc()==89;
      }gc();
      for(int i=0;i<t;i++){
          a=gc()==89;
          s+=((arr[i]|a)<<1)|(arr[i]&a);
      }write_(s);
      
      • 1

      信息

      ID
      136
      时间
      1000ms
      内存
      256MiB
      难度
      8
      标签
      递交数
      78
      已通过
      12
      上传者