# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
712019 |
2023-03-18T00:40:23 Z |
pcc |
Checker (COCI19_checker) |
C++14 |
|
378 ms |
108804 KB |
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fs first
#define sc second
struct node{
set<pii> st;
int pre,nxt;
bool del;
node(){
pre = nxt = 0;
del = false;
}
void add(int to,int c){
st.insert({to,c});
}
int get(int k){
auto it = st.upper_bound(make_pair(k,-1));
if(it == st.end()||it->fs != k)return 0;
return it->sc;
}
};
const int mxn = 2e5+10;
node v[mxn];
void remov(int k){
v[v[k].pre].nxt = v[k].nxt;
v[v[k].nxt].pre = v[k].pre;
v[k].del = true;
return;
}
bool dif(int a,int b,int c){
if(!a||!b||!c)return 0;
if(a == b||c == b||a == c)return 0;
return 1;
}
int pos[mxn];
vector<pii> edges;
int n;
bool cmp(pii a,pii b){
int l1 = min(a.sc-a.fs,n-(a.sc-a.fs));
int l2 = min(b.sc-b.fs,n-(b.sc-b.fs));
return l1<l2;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>n;
string col;
cin>>col;
for(int i = 1;i<n;i++){
v[i].add(i+1,col[i-1]-'0');
v[i+1].add(i,col[i-1]-'0');
}
v[n].add(1,col.back()-'0');
v[1].add(n,col.back()-'0');
for(int i = 0;i<n-3;i++){
int a,b,c;
cin>>a>>b>>c;
edges.push_back({min(a,b),max(a,b)});
v[a].add(b,c);
v[b].add(a,c);
}
for(int i = 1;i<=n;i++)v[i].pre = i-1;
for(int i = n-1;i>=1;i--)v[i].nxt = i+1;
v[1].pre = n;
v[n].nxt = 1;
sort(edges.begin(),edges.end(),cmp);
bool flag = true;
for(auto &i:edges){
int a = i.fs,b = i.sc;
if(v[a].del||v[b].del){
cout<<"neispravna triangulacija\n";
return 0;
}
if(v[v[b].pre].pre != a)swap(a,b);
if(!dif(v[b].get(v[b].pre),v[b].get(a),v[a].get(v[b].pre))){
flag = false;
}
if(v[v[b].pre].pre == a){
remov(v[b].pre);
}
else{
assert(false);
cout<<"neispravna triangulacija\n";
return 0;
}
}
if(flag){
cout<<"tocno\n";
}
else cout<<"neispravno bojenje\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
12756 KB |
Output is correct |
2 |
Correct |
7 ms |
12828 KB |
Output is correct |
3 |
Runtime error |
22 ms |
25904 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
12756 KB |
Output is correct |
2 |
Correct |
7 ms |
12828 KB |
Output is correct |
3 |
Runtime error |
22 ms |
25904 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
325 ms |
52140 KB |
Output is correct |
2 |
Correct |
324 ms |
55228 KB |
Output is correct |
3 |
Runtime error |
320 ms |
108804 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
321 ms |
52240 KB |
Output is correct |
2 |
Correct |
326 ms |
55220 KB |
Output is correct |
3 |
Correct |
356 ms |
55256 KB |
Output is correct |
4 |
Correct |
338 ms |
55276 KB |
Output is correct |
5 |
Correct |
360 ms |
55284 KB |
Output is correct |
6 |
Correct |
362 ms |
55264 KB |
Output is correct |
7 |
Correct |
345 ms |
55452 KB |
Output is correct |
8 |
Correct |
378 ms |
55300 KB |
Output is correct |
9 |
Correct |
326 ms |
55192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
12756 KB |
Output is correct |
2 |
Correct |
7 ms |
12828 KB |
Output is correct |
3 |
Runtime error |
22 ms |
25904 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |