제출 #222394

#제출 시각아이디문제언어결과실행 시간메모리
222394oolimryChecker (COCI19_checker)C++14
23 / 110
138 ms6900 KiB
    #include <bits/stdc++.h>
     
    using namespace std;
    typedef pair<int,int> ii;
    struct bracket{
    	int pos; int other; bool open;
    };
    bool comp(bracket a, bracket b){
    	if(a.pos != b.pos) return a.pos < b.pos;
    	
    	if(a.open && !b.open) return false;
    	if(!a.open && b.open) return true;
    	
    	if(a.open){
    		return a.other > b.other;
    	}
    	else{
    		return a.other > b.other;
    	}
    }
     
    void notTriangle(){
    	cout << "neispravna triangulacija";
    	exit(0);
    }
     
    int main(){
    	//freopen("i.txt","r",stdin);
    	ios_base::sync_with_stdio(false);
    	int ST; cin >> ST;
    	
    	int n; cin >> n;
    	string S; cin >> S;
    	
    	vector<bracket> B;
    	for(int i = 0;i < n-3;i++){
    		int l, r, c; cin >> l >> r >> c;
    		if(l > r) swap(l,r);
    		B.push_back({l,r,true});
    		B.push_back({r,l,false});
    	}
    	
    	sort(B.begin(),B.end(),comp);
    	
    	
    	stack<ii> s;
    	for(bracket b : B){
    		//cout << b.pos << " " << b.other << " " << b.open << endl;
    		if(b.open) s.push(ii(b.pos,b.other));
    		else{
    			ii t = s.top();
    			if(t.first != b.other && t.second != b.pos){
    				notTriangle();
    			}
    			else s.pop();
    		}
    	}
    	
    	
    	
    	
    	
    	cout << "tocno";
    	
    }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...