답안 #362107

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
362107 2021-02-01T19:05:44 Z limabeans Checker (COCI19_checker) C++17
0 / 110
855 ms 21160 KB
#include <bits/stdc++.h>
using namespace std;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




const int maxn = 1e6 + 5;

const string BADTRI = "neispravna triangulacija";
const string NOTPAT = "neispravno bojenje";
const string GOOD = "tocno";


struct iv {
    int l,r,c;
    void read() {
	cin>>l>>r>>c;
	--l; --r;
    }
};

int n;
string s;
vector<iv> w;


int dist(int l, int r) {
    return (r-l+n)%n;

}

string solve() {
    w.clear();
    cin>>n;
    cin>>s;
    w.resize(n-3);
    for (int i=0; i<n-3; i++) {
	w[i].read();
    }
    vector<pair<int,int>> nxt(n);
    for (int i=0; i<n; i++) {
	nxt[i].first = (i+1)%n;
	nxt[i].second = int(s[i]-'0');
    }

    vector<pair<pair<int,int>,int>> diags;
    for (auto p: w) {
	diags.push_back({{p.l,p.r},p.c});
	diags.push_back({{p.r,p.l},p.c});
    }

    sort(diags.begin(), diags.end(), [&](pair<pair<int,int>,int> a, pair<pair<int,int>,int> b) {
	return dist(a.first.first,a.first.second) < dist(b.first.first,b.first.second);
    });



    for (int i=0; i<n-2; i++) {
	auto cur = diags[i];
	cout<<cur.first.first+1<<" "<<cur.first.second+1<<endl;
	
	int a = cur.first.first;
	int b = nxt[a].first;
	int c = cur.first.second;
	if (nxt[b].first != c) {
	    return BADTRI;
	}
	vector<int> colors = {cur.second, nxt[a].second, nxt[b].second};
	if ((int)set<int>(colors.begin(), colors.end()).size() < 3) {
	    return NOTPAT;
	}

	nxt[a] = {c, cur.second};
    }


    return GOOD;
}


int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

    int t;
    cin>>t;
    while (t--) {
	cout<<solve()<<"\n";
    }
    
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 800 ms 21160 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 855 ms 21120 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -