1 条题解

  • -2
    @ 2025-4-28 8:59:13

    对于那个百分之20的特殊性质

    我们可以发现只需先从前往后扫一遍然后相邻为逆序的输出,然后从后往前扫一遍相邻顺序的输出

    然后对于100%的数据

    我们对相同的且相邻的数缩为一点,然后就会变为那个特殊的性质,赛时没想到

    然后就做完了

    #include <bits/stdc++.h>
    using namespace std;
    
    bool mlest;
    
    double tlest, tleed;
    
    inline int R(){
    	int x = 0, f = 1;char ch = getchar();
    	while(!isdigit(ch)){if(ch == '-') f = -1;ch = getchar();}
    	while(isdigit(ch)){x = (x << 1) + (x << 3) + (ch ^ 48);ch = getchar();}
    	return x * f;
    }
    
    inline void W(int x){
    	if(x < 0){x = -x;putchar('-');}
    	if(x > 9) W(x/10);putchar(x%10+'0');
    }
    
    const int N = 1e6 + 10;
    
    int n;
    
    string s;
    
    vector<int> e[N]; 
    
    void read(){
    	cin >> n;
    	s = " ";
    	for(int i = 1;i <= n; i++){
    		char c;
    		cin >> c;
    		if(c == s[s.size()-1]){
    			e[s.size()-1].push_back(i);
    		}
    		else{
    			s = s + c;
    			e[s.size()-1].push_back(i);
    		}
    	}
    	s = s + (char)('z'+1);
    }
    
    void init(){
    
    }
    
    void compute(){
    	for(int i = 1;i < s.size() - 2; i++){
    		if(s[i] > s[i + 1]) {
    			for(int v : e[i]){
    				cout << v << ' ';
    			}
    		}
    	}
    	for(int i = s.size() - 1;i > 1; i--){
    		if(s[i-1] < s[i]) {
    			for(int v : e[i-1]){
    				cout << v << ' ';
    			}
    		}
    	}
    }
    
    void clear(){
    
    }
    
    void run() { read(); init(); compute(); clear(); }
    
    bool mleed;
    
    void wa() { cout << "\n" << tleed-tlest << "ms\n" << (&mleed-&mlest-1)/1024.0/1024.0 << "MB\n"; }
    
    void fre(string s){
    	freopen((s+".in").c_str(),"r",stdin);
    	freopen((s+".out").c_str(),"w",stdout);
    }
    
    int main(){
    //	fre("");
    	tlest = clock();
    	run();
    	tleed = clock();
    //	wa();
    	return 0;
    }
    
    
    
  • 1

信息

ID
188
时间
1000ms
内存
256MiB
难度
5
标签
(无)
递交数
29
已通过
14
上传者