This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n>>n;
string s;
cin>>s;
vector<pair<int,int>> nei[n+1];
bitset<200000> edg[n][3],temp;
for (int i=0;i<n-1;i++)
{
nei[i].push_back({i+1,s[i]});
nei[i+1].push_back({i,s[i]});
edg[i][s[i]-'1'].set(i+1);
edg[i+1][s[i]-'1'].set(i);
}
nei[0].push_back({n-1,s[n-1]});
nei[n-1].push_back({0,s[n-1]});
edg[0][s[n-1]-'1'].set(n-1);
edg[n-1][s[n-1]-'1'].set(0);
for (int i=0;i<n-3;i++)
{
int u,v,w;
cin>>u>>v>>w;
u--,v--,w--;
nei[u].push_back({v,w});
nei[v].push_back({u,w});
edg[u][w].set(v);
edg[v][w].set(u);
}
int tr=0,ptr=0;
for (int u=0;u<n;u++)
{
for (auto i:nei[u])
for (int j=0;j<3;j++)
for (int k=0;k<3;k++)
{
temp=edg[u][j]&edg[i.first][k];
tr+=temp.count();
if (j!=k && i.second!=j && i.second!=k)
ptr+=temp.count();
}
}
tr/=6;
ptr/=6;
if (tr!=n-2)
cout<<"neispravna triangulacija"<<endl;
else if(ptr!=n-2)
cout<<"neispravno bojenje"<<endl;
else
cout<<"tocno"<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |