#include<bits/stdc++.h>
using namespace std;
#define int long long
#define X first
#define Y second
int ttt;
int n;
vector<pair<int,int>>e[200005];
vector<pair<int,int>>ne[200005];
vector<int>inter[400005];
bool cmp(int i,int j){
if(e[i].size()<e[j].size()){return 1;}
if(e[i].size()>e[j].size()){return 0;}
return i<j;
}
bool cmp2(pair<int,int>i,pair<int,int>j){
return cmp(i.first,j.first);
}
int clr[400005];/*
bool cyc3(){
for(int i=1;i<=n;i++){
for(int j=0;j<e[i].size();j++){
int v=e[i][j].first;
if(cmp(i,v)){
ne[i].push_back({v,e[i].second});
}
}
sort(ne[i].begin(),ne[i].end());
}
int ret=0;
for(int a=1;a<=n;a++){
for(pair<int,int>pr:ne[a]){
int b=pr.first;
clr[b]=pr.second;
for(pair<int,int>pr2:ne[b]){
int c=pr.first;
if(mp[{a,c}]&&pr.second+clr[c]+mp[{a,c}]%3==0){
ret++;
}
}
}
}
return ret==n-2;
}
*/
bool cmpp(pair<int,int>i,pair<int,int>j){
if(i.first<j.first){return 1;}
if(i.first>j.first){return 0;}
return i.second>j.second;
}
void solve(){
cin>>n;
string s;
for(int i=1;i<=n;i++){
clr[i]=0;
e[i].clear();
ne[i].clear();
}
cin>>s;
for(int i=0;i<s.size();i++){
int v=s[i]-'0';
int a=i+1;int b=i+2;
if(i==n-1){
b=1;
}
e[a].push_back({b,v});
e[b].push_back({a,v});
}
vector<pair<int,int>>seg;
for(int i=1;i<=n-3;i++){
int a;int b;int c;
cin>>a>>b>>c;
if(a>b){swap(a,b);}
e[a].push_back({b,c});
e[b].push_back({a,c});
seg.push_back({a,b});
// seg.push_back({b,a+n});
}
sort(seg.begin(),seg.end(),cmpp);
int rt=seg[0].second;
/*for(int i=0;i<seg.size();i++){
cout<<seg[i].first<<" "<<seg[i].second<<"\n";
}*/
for(int i=1;i<seg.size();i++){
if(seg[i].first<rt&&seg[i].second>rt){
cout<<"neispravna triangulacija\n";
return;
}
rt=max(rt,seg[i].second);
}
cout<<"tocno\n";
}
signed main(){
cin>>ttt;
while(ttt--)solve();
}
Compilation message
checker.cpp: In function 'void solve()':
checker.cpp:63:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | for(int i=0;i<s.size();i++){
| ~^~~~~~~~~
checker.cpp:87:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
87 | for(int i=1;i<seg.size();i++){
| ~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
20060 KB |
Output is correct |
2 |
Correct |
5 ms |
20060 KB |
Output is correct |
3 |
Incorrect |
5 ms |
20060 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
20060 KB |
Output is correct |
2 |
Correct |
5 ms |
20060 KB |
Output is correct |
3 |
Incorrect |
5 ms |
20060 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
274 ms |
61624 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
277 ms |
61780 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
20060 KB |
Output is correct |
2 |
Correct |
5 ms |
20060 KB |
Output is correct |
3 |
Incorrect |
5 ms |
20060 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |