Submission #508633

# Submission time Handle Problem Language Result Execution time Memory
508633 2022-01-13T13:13:39 Z inksamurai Sajam (COCI18_sajam) C++17
15 / 90
32 ms 21484 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _34raRxL ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;

void print(){
	cout<<"\n";
}
template<class te,class ...ti>
void print(const te&v, const ti&...nv) { 
	cout<<v;
	if(sizeof...(nv)){
		cout<<" ";
		print(nv...);
	}
}

#define yare {cout<<"DA\n"; exit(0);}
#define nare {cout<<"NE\n"; exit(0);}

using pii=pair<int,int>;
using vi=vector<int>;
using vll=vector<long long>;

signed main(){
_34raRxL;
	int n,k;
	cin>>n>>k;
	int h=n,w=n;
	vec(vi) a(h,vi(w));
	rep(i,h){
		string s;
		cin>>s;
		rep(j,w){
			a[i][j]=s[j]=='o';
		}
	}
	vec(vec(pii)) adj(2*n);
	rep(i,h){
		rep(j,w){
			int x=a[i][j];
			// co = j + n ..
			int ro=i,co=j+n;
			adj[ro].pb({co,x});
			adj[co].pb({ro,x});
		}
	}
	vi usd(2*n,-1);
	auto dfs=[&](auto self,int v)->void{
		for(auto edge : adj[v]){
			int cost=edge.se,u=edge.fi;
			if(usd[u]==-1){
				usd[u]=usd[v]^cost;
				self(self,u);
			}else if(usd[u]!=-1 and usd[u]!=(usd[v]^cost)){
				nare;
			}
		}
	};
	usd[0]=0;
	dfs(dfs,0);
	rep(i,h){
		rep(j,w){
			int x=a[i][j];
			int ro=i,co=j+n;
			if((usd[ro]^usd[co])!=x){
				nare;
			}
		}
	}
	yare;
//	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 6 ms 4660 KB Output is correct
3 Correct 11 ms 10040 KB Output is correct
4 Correct 31 ms 19220 KB Output is correct
5 Correct 13 ms 10076 KB Output is correct
6 Correct 5 ms 3468 KB Output is correct
7 Correct 9 ms 5564 KB Output is correct
8 Correct 28 ms 19580 KB Output is correct
9 Correct 3 ms 1484 KB Output is correct
10 Correct 28 ms 19876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Incorrect 1 ms 460 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 15208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 18124 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 12976 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 21484 KB Output isn't correct
2 Halted 0 ms 0 KB -