Search found 73 matches
- Tue Dec 26, 2017 4:01 pm
- Forum: Volume 12 (1200-1299)
- Topic: 1242 - Necklace
- Replies: 2
- Views: 1832
Re: 1242 - Necklace
Nevermind, I now know why that scheme will fail.
- Tue Dec 26, 2017 3:21 pm
- Forum: Volume 12 (1200-1299)
- Topic: 1242 - Necklace
- Replies: 2
- Views: 1832
Re: 1242 - Necklace
Does doing BFS twice (making sure to not use an edge twice) work? My code matches Morass' output on uDebug. #include <bits/stdc++.h> using namespace std; typedef pair<int,int> pi; typedef tuple<int,int,int> t3; bool edge_used[100000+10]; vector<vector<pi>> adjList; // adj, edge_id int N,M; int S,T; ...
- Sun Jun 12, 2016 7:00 pm
- Forum: Volume 113 (11300-11399)
- Topic: 11380 - Down Went The Titanic
- Replies: 19
- Views: 12358
Re: 11380 - Down Went The Titanic
Why WA? I've been passing all the test cases. #include <bits/stdc++.h> using namespace std; char input[32][32]; int res[32][32][2][5]; int src_res[32][32]; int sink_res[32][23]; typedef pair<int, int> pi; typedef pair<int, pi> pii; #define INF (1<<28) class bfs_node{ public: int row, col; int flow; ...
- Mon Feb 22, 2016 6:07 pm
- Forum: Volume 12 (1200-1299)
- Topic: 1252 - Twenty Questions
- Replies: 7
- Views: 3086
Re: 1252 - Twenty Questions
Getting WA. What did I miss? #include <bits/stdc++.h> using namespace std; #define INF 1<<28 #define UNVISITED -1 typedef bitset<11> bset; typedef unsigned long ul; int N, M; vector<string> input; vector<bset> input_bs; int arr[1<<11][11][1<<11]; // int f(bset bs, int index){ // ul ulong = bs.to_ulo...
- Fri Sep 11, 2015 6:36 am
- Forum: Volume 114 (11400-11499)
- Topic: 11418 - Clever Naming Patterns
- Replies: 9
- Views: 6338
Re: 11418 - Clever Naming Patterns
Why TLE? #include <bits/stdc++.h> using namespace std; vector<vector<string>> input; vector<int> sz; int N; int totalNodes; bool hasLetter(int index, char letter){ int num = sz[index]; for(int i = 0; i<num; i++){ if(letter == toupper(input[index][i][0])){ return true; } } return false; } int getInde...
- Sun Jul 26, 2015 4:15 pm
- Forum: Volume 104 (10400-10499)
- Topic: 10475 - Help the Leaders
- Replies: 24
- Views: 13497
Re: 10475 - Help the Leaders
Why WA? #include <bits/stdc++.h> using namespace std; bool lexcmp(string a, string b){ int asz = a.size(); int bsz = b.size(); if(asz == bsz) return a < b; return asz > bsz; } set<int> build; // map<string, set<string>> prohibited; vector<set<int>> prohibited; vector<string> input; map<string, int> ...
- Sat Jul 25, 2015 6:37 am
- Forum: Volume 7 (700-799)
- Topic: 775 - Hamiltonian Cycle
- Replies: 11
- Views: 4744
Re: 775 - Hamiltonian Cycle
Why is it RE? I've already tried implementing it with a stack. #include <bits/stdc++.h> using namespace std; int N; vector<vector<int>> adjMat; int toInt(string &str){ int cnt = 0; for(auto itr = str.rbegin(); itr!=str.rend(); ++itr){ cnt *= 10; cnt += *itr - '0'; } // cout << "transformed ...
- Thu Jul 23, 2015 8:14 am
- Forum: Volume 3 (300-399)
- Topic: 331 - Mapping the Swaps
- Replies: 11
- Views: 7568
Re: 331 - Mapping the Swaps
Why is mine RE? Could it be due to the recursion stack being too deep? I've tried it with 5 and even 6 as the array size. #include <bits/stdc++.h> using namespace std; #define INF 1<<26 int N; vector<int> input; vector<int> orig; vector<int> swap_map; void printOrig(){ for(int i = 0; i<orig.size(); ...
- Thu Jul 02, 2015 7:59 am
- Forum: Volume 110 (11000-11099)
- Topic: 11002 - Towards Zero
- Replies: 39
- Views: 21604
Re: 11002 - Towards Zero
Getting TLE a couple of times now. #include <bits/stdc++.h> using namespace std; #define INF 1<<26 #define UNVISITED -1 int offset; int input[59][30]; int max_val; int arr [59][30][3001]; // bool visited[59][30][3001]; int N; int f(int i, int j, int sum){ // printf("%d %d %d %d\n", i,j,sum...
- Tue Jun 30, 2015 4:40 pm
- Forum: Volume 113 (11300-11399)
- Topic: 11391 - Blobs in the Board
- Replies: 10
- Views: 5952
Re: 11391 - Blobs in the Board
Why WA? Any more test cases? #include <bits/stdc++.h> using namespace std; typedef unsigned long ul; typedef bitset<16> bset; typedef long long ll; #define UNVISITED -1 int R, C, N; int RC; void toCoord(int index, int * i, int * j){ *i = index/C; *j = index%C; } int toIndex(int i, int j){ int ret = ...
- Thu Jun 18, 2015 8:45 am
- Forum: Volume 100 (10000-10099)
- Topic: 10069 - Distinct Subsequences
- Replies: 26
- Views: 18423
Re: 10069 - Distinct Subsequences
According to Halim's book CP3, you really need to use BigInt.
- Thu Jun 18, 2015 8:35 am
- Forum: Volume 108 (10800-10899)
- Topic: 10898 - Combo Deal
- Replies: 9
- Views: 7678
Re: 10898 - Combo Deal
What is the recommended way to scan doubles and typecast to int? For example, if I'm reading 9.14, and I want it to be 914, I would do: scan as double, multiply that double by 100, then typecast to int. double f; cin >> f; f*=100; int i = (int) f; For this problem, I think one can do "%d.%d&quo...
- Mon Jun 15, 2015 9:18 am
- Forum: Volume 100 (10000-10099)
- Topic: 10069 - Distinct Subsequences
- Replies: 26
- Views: 18423
Re: 10069 - Distinct Subsequences
Why WA? AC with Java BigInt If we're following uDebug's cases, then it's the BigInt problem. I've coded it in python, and the same logic gives the same answer for the first case, and for the second, it gives off a RuntimeError, exceeding maximum recursion depth. uDebug input: 2 aaaaaaaaaaaaaaaaaaaaa...
- Thu May 14, 2015 3:02 am
- Forum: Volume 100 (10000-10099)
- Topic: 10069 - Distinct Subsequences
- Replies: 26
- Views: 18423
Re: 10069 - Distinct Subsequences
...which I also can't find. (along with delete).
Anyway, how come it's about big integer? I thought that "Z nor any prefix or suffix of Z will have more than 10100 distinct occurrences in X as a subsequence."
Anyway, how come it's about big integer? I thought that "Z nor any prefix or suffix of Z will have more than 10100 distinct occurrences in X as a subsequence."
- Thu May 14, 2015 2:59 am
- Forum: Volume 100 (10000-10099)
- Topic: 10069 - Distinct Subsequences
- Replies: 26
- Views: 18423
Re: 10069 - Distinct Subsequences
There should be near the post.