Submission #92023

# Submission time Handle Problem Language Result Execution time Memory
92023 2019-01-01T06:20:26 Z bharat2002 Praktični (COCI18_prakticni) C++14
26 / 130
334 ms 19744 KB
/*input
6 8
1 2 6
2 3 1
3 5 6
	3 1 5
4 5 0
3 6 0
	4 2 8
	4 1 1
*/
#include<bits/stdc++.h>
using namespace std;
const int N=1e5 + 100;
const int mod=1e9 + 7;
#define int long long
class pii 
{	
public:
	int f, s, ind;
};
inline pii mp(int a, int b, int c)
{
	pii t;t.f=a;t.s=b;t.ind=c;return t;
}
inline pair<int, int> makep(int a, int b)
{
	pair<int, int> t;t.first=a;t.second=b;return t;
}
vector< pii > adjlist[N];int n, m;
vector< pair<int, int> > req;bool visited[N];int xval[N];
map<vector<int>, int> queries;
void dfs(int i, int p)
{
	visited[i]=1;
	for(auto j:adjlist[i])
	{
		if(visited[j.f]&&j.f!=p)
		{
			req.push_back(make_pair(j.ind, (j.s^xval[i]^xval[j.f])));continue;
		}
		else if(!visited[j.f])
		{
			xval[j.f]=(xval[i]^j.s);dfs(j.f, i);
		}
	}
}
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int u, v, w;cin>>u>>v>>w;adjlist[u].push_back(mp(v, w, i));adjlist[v].push_back(mp(u, w, i));
	}
	for(int i=1;i<=n;i++)
	{
		visited[i]=xval[i]=0;
	}
	dfs(1, -1);
	for(int i=0;i<31;i++)
	{
		set<int> inds;
		for(auto j:req)
		{
			if((j.second&(1<<i))) inds.insert(j.first);
		}
		if(inds.empty()) continue;
		vector<int> temp;
		for(auto j:inds) temp.push_back(j);
		queries[temp]^=(1<<i);
	}
	cout<<queries.size()<<endl;
	for(auto it=queries.begin();it!=queries.end();it++)
	{
		cout<<it->second<<" "<<it->first.size()<<" ";
		for(auto j:it->first) cout<<j<<" ";cout<<endl;
	}
}

Compilation message

parkticni.cpp: In function 'int main()':
parkticni.cpp:58:21: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   visited[i]=xval[i]=0;
              ~~~~~~~^~
parkticni.cpp:77:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   for(auto j:it->first) cout<<j<<" ";cout<<endl;
   ^~~
parkticni.cpp:77:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   for(auto j:it->first) cout<<j<<" ";cout<<endl;
                                      ^~~~
# Verdict Execution time Memory Grader output
1 Correct 97 ms 8936 KB Output is correct
2 Correct 57 ms 8440 KB Output is correct
3 Correct 23 ms 4600 KB Output is correct
4 Correct 10 ms 4088 KB Output is correct
5 Correct 89 ms 13560 KB Output is correct
6 Correct 87 ms 12536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 6004 KB Output is correct
2 Correct 18 ms 5876 KB Output is correct
3 Correct 24 ms 6264 KB Output is correct
4 Correct 27 ms 6904 KB Output is correct
5 Correct 182 ms 14184 KB Output is correct
6 Correct 103 ms 9832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 85 ms 9864 KB Too many operations
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 122 ms 13032 KB Too many operations
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 101 ms 11764 KB Too many operations
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 334 ms 18664 KB Too many operations
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 128 ms 13120 KB Too many operations
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 313 ms 19744 KB Too many operations
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 5880 KB Too many operations
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 157 ms 14572 KB Too many operations
2 Halted 0 ms 0 KB -