Submission #889754

#TimeUsernameProblemLanguageResultExecution timeMemory
889754vjudge1Nautilus (BOI19_nautilus)C++17
0 / 100
0 ms344 KiB
//#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3") //#pragma GCC target( "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> #define len(x) (int)x.size() #define ull unsigned long long #define F first #define S second #define pb push_back #define pf push_front #define popb pop_back #define popf pop_front #define int long long #define ld long double #define pii pair<int,int> #define mii map<int,int> using namespace std; using namespace __gnu_pbds; using ll = long long; const int N = 2e5 + 5; const int MOD = 1e9 + 7; const ll INF = 1e18; const ll inf = 1e9; int n,m,k; string s,a[505]; set <pii> st; pii go (int x, int y){ for (int i=0;i<k;i++){ if (s[i] == 'W'){ y--; if (y < 0 || a[x][y]=='#'){ return {-1, -1}; } } else if (s[i]=='N'){ x++; if (x < n || a[x][y]=='#'){ return {-1, -1}; } } else if (s[i]=='E'){ y++; if (y < m || a[x][y]=='#'){ return {-1, -1}; } } else{ x--; if (x < 0 || a[x][y]=='#'){ return {-1, -1}; } } } return {x, y}; } signed main(){ // freopen("txt.in", "r", stdin); // freopen("txt.out", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m >> k; for (int i=0;i<n;i++){ cin >> a[i]; } cin >> s; for (int i=0;i<n;i++){ for (int j=0;j<m;j++){ pii res = go(i, j); if (res.F!=-1){ st.insert(res); } } } cout << len(st); } //order_of_key(k): Number of items strictly smaller than k . //find_by_order(k): K-th element in a set (counting from zero). //sum of squares n*(n+1)*(2n+1)/6 //sum of cubes [n*(n+1)/2]^2 //sum of squares for odds n*(4*n*n-1)/3 //sum of cubes for odds n*n*(2*n*n-1) //a/b%mod = a*(b^(m-2)%mod) //(a>>x)&1 == 0 //a^b = (a+b)-2(a&b) //srand(time(0))-always changing
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...