-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75e90a1
commit 8c3d039
Showing
64 changed files
with
2,002 additions
and
2,002 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# depslib dependency file v1.0 | ||
1487534351 source:g:\code c++\sphere\aggrcow - aggressive cows\main.cpp | ||
<bits/stdc++.h> | ||
|
||
# depslib dependency file v1.0 | ||
1487534351 source:g:\code c++\sphere\aggrcow - aggressive cows\main.cpp | ||
<bits/stdc++.h> | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,62 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
typedef long long int ll; | ||
ll pos[123456]; | ||
ll N, C; | ||
|
||
bool F(ll x){ | ||
ll cowsplaced = 1, lastpos = pos[0]; | ||
for(ll i = 1; i < N; i++){ | ||
if(pos[i] - lastpos >= x){ | ||
lastpos = pos[i]; | ||
cowsplaced++; | ||
if(cowsplaced == C){ | ||
return 1; | ||
} | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
ll binarySearch(){ | ||
//sort(pos, pos + N); | ||
ll start = 0, ed = pos[N - 1], mx = -1; | ||
while(start < ed){ | ||
int mid = start + (ed - start)/2; | ||
if(F(mid) == 1){ | ||
if(mid > mx){ | ||
mx = mid; | ||
} | ||
start = mid + 1; | ||
} | ||
else{ | ||
ed = mid; | ||
} | ||
} | ||
return mx; | ||
} | ||
|
||
int main() { | ||
ll T; | ||
scanf("%lld",&T); | ||
while(T--){ | ||
scanf("%lld%lld",&N,&C); | ||
for(ll i = 0;i<N;i++){ | ||
scanf("%lld",&pos[i]); | ||
} | ||
//printf("%lld\n",binarySearch()); | ||
sort(pos, pos + N); | ||
cout << binarySearch() << "\n"; | ||
} | ||
|
||
return 0; | ||
} | ||
/** | ||
1 | ||
5 3 | ||
1 | ||
2 | ||
8 | ||
4 | ||
9 | ||
*/ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
typedef long long int ll; | ||
ll pos[123456]; | ||
ll N, C; | ||
|
||
bool F(ll x){ | ||
ll cowsplaced = 1, lastpos = pos[0]; | ||
for(ll i = 1; i < N; i++){ | ||
if(pos[i] - lastpos >= x){ | ||
lastpos = pos[i]; | ||
cowsplaced++; | ||
if(cowsplaced == C){ | ||
return 1; | ||
} | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
ll binarySearch(){ | ||
//sort(pos, pos + N); | ||
ll start = 0, ed = pos[N - 1], mx = -1; | ||
while(start < ed){ | ||
int mid = start + (ed - start)/2; | ||
if(F(mid) == 1){ | ||
if(mid > mx){ | ||
mx = mid; | ||
} | ||
start = mid + 1; | ||
} | ||
else{ | ||
ed = mid; | ||
} | ||
} | ||
return mx; | ||
} | ||
|
||
int main() { | ||
ll T; | ||
scanf("%lld",&T); | ||
while(T--){ | ||
scanf("%lld%lld",&N,&C); | ||
for(ll i = 0;i<N;i++){ | ||
scanf("%lld",&pos[i]); | ||
} | ||
//printf("%lld\n",binarySearch()); | ||
sort(pos, pos + N); | ||
cout << binarySearch() << "\n"; | ||
} | ||
|
||
return 0; | ||
} | ||
/** | ||
1 | ||
5 3 | ||
1 | ||
2 | ||
8 | ||
4 | ||
9 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
def Main(T): | ||
for _ in range(T): | ||
s = input() | ||
sm = 0 | ||
for i in range(len(s)): | ||
a = int(s[i]) | ||
sm += a | ||
print(sm) | ||
|
||
|
||
if __name__ == '__main__': | ||
T = int(input()) | ||
def Main(T): | ||
for _ in range(T): | ||
s = input() | ||
sm = 0 | ||
for i in range(len(s)): | ||
a = int(s[i]) | ||
sm += a | ||
print(sm) | ||
|
||
|
||
if __name__ == '__main__': | ||
T = int(input()) | ||
Main(T) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
''' | ||
Created on May 20, 2016 | ||
@author: Md. Rezwanul Haque | ||
''' | ||
n = int(input()) | ||
ans = 0 | ||
rezwan = 0 | ||
for i in range(n): | ||
a,b = map(int,input().split()) | ||
A = int(str(a)[::-1])#reverse | ||
B = int(str(b)[::-1])#reverse | ||
ans = A + B | ||
rezwan = int(str(ans)[::-1])#reverse | ||
print(rezwan) | ||
''' | ||
Created on May 20, 2016 | ||
@author: Md. Rezwanul Haque | ||
''' | ||
n = int(input()) | ||
ans = 0 | ||
rezwan = 0 | ||
for i in range(n): | ||
a,b = map(int,input().split()) | ||
A = int(str(a)[::-1])#reverse | ||
B = int(str(b)[::-1])#reverse | ||
ans = A + B | ||
rezwan = int(str(ans)[::-1])#reverse | ||
print(rezwan) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
<CodeBlocks_project_file> | ||
<FileVersion major="1" minor="6" /> | ||
<Project> | ||
<Option title="Aibohphobia" /> | ||
<Option pch_mode="2" /> | ||
<Option compiler="gcc" /> | ||
<Build> | ||
<Target title="Debug"> | ||
<Option output="bin/Debug/Aibohphobia" prefix_auto="1" extension_auto="1" /> | ||
<Option object_output="obj/Debug/" /> | ||
<Option type="1" /> | ||
<Option compiler="gcc" /> | ||
<Compiler> | ||
<Add option="-g" /> | ||
</Compiler> | ||
</Target> | ||
<Target title="Release"> | ||
<Option output="bin/Release/Aibohphobia" prefix_auto="1" extension_auto="1" /> | ||
<Option object_output="obj/Release/" /> | ||
<Option type="1" /> | ||
<Option compiler="gcc" /> | ||
<Compiler> | ||
<Add option="-O2" /> | ||
</Compiler> | ||
<Linker> | ||
<Add option="-s" /> | ||
</Linker> | ||
</Target> | ||
</Build> | ||
<Compiler> | ||
<Add option="-Wall" /> | ||
<Add option="-fexceptions" /> | ||
</Compiler> | ||
<Unit filename="main.cpp" /> | ||
<Extensions> | ||
<code_completion /> | ||
<envvars /> | ||
<debugger /> | ||
</Extensions> | ||
</Project> | ||
</CodeBlocks_project_file> | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
<CodeBlocks_project_file> | ||
<FileVersion major="1" minor="6" /> | ||
<Project> | ||
<Option title="Aibohphobia" /> | ||
<Option pch_mode="2" /> | ||
<Option compiler="gcc" /> | ||
<Build> | ||
<Target title="Debug"> | ||
<Option output="bin/Debug/Aibohphobia" prefix_auto="1" extension_auto="1" /> | ||
<Option object_output="obj/Debug/" /> | ||
<Option type="1" /> | ||
<Option compiler="gcc" /> | ||
<Compiler> | ||
<Add option="-g" /> | ||
</Compiler> | ||
</Target> | ||
<Target title="Release"> | ||
<Option output="bin/Release/Aibohphobia" prefix_auto="1" extension_auto="1" /> | ||
<Option object_output="obj/Release/" /> | ||
<Option type="1" /> | ||
<Option compiler="gcc" /> | ||
<Compiler> | ||
<Add option="-O2" /> | ||
</Compiler> | ||
<Linker> | ||
<Add option="-s" /> | ||
</Linker> | ||
</Target> | ||
</Build> | ||
<Compiler> | ||
<Add option="-Wall" /> | ||
<Add option="-fexceptions" /> | ||
</Compiler> | ||
<Unit filename="main.cpp" /> | ||
<Extensions> | ||
<code_completion /> | ||
<envvars /> | ||
<debugger /> | ||
</Extensions> | ||
</Project> | ||
</CodeBlocks_project_file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
<CodeBlocks_layout_file> | ||
<FileVersion major="1" minor="0" /> | ||
<ActiveTarget name="Debug" /> | ||
<File name="main.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> | ||
<Cursor> | ||
<Cursor1 position="458" topLine="0" /> | ||
</Cursor> | ||
</File> | ||
</CodeBlocks_layout_file> | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
<CodeBlocks_layout_file> | ||
<FileVersion major="1" minor="0" /> | ||
<ActiveTarget name="Debug" /> | ||
<File name="main.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> | ||
<Cursor> | ||
<Cursor1 position="458" topLine="0" /> | ||
</Cursor> | ||
</File> | ||
</CodeBlocks_layout_file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int LCS(string X, string Y, int m, int n){ | ||
int dp[m+1][n+1]; | ||
|
||
for(int i=0;i<=m;i++){ | ||
for(int j=0;j<=n;j++){ | ||
if(i == 0 || j == 0){ | ||
dp[i][j] = 0; | ||
} | ||
else if(X[i - 1] == Y[j - 1]){ | ||
dp[i][j] = dp[i - 1][j - 1] + 1; | ||
} | ||
else{ | ||
dp[i][j] = max(dp[i-1][j], dp[i][j-1]); | ||
} | ||
} | ||
} | ||
//cout << dp[m][n] << endl; | ||
return dp[m][n]; | ||
} | ||
|
||
int main() | ||
{ | ||
//LCS("fft", "tff" , 3, 3); | ||
|
||
int T; | ||
scanf("%d",&T); | ||
|
||
while(T--){ | ||
string s1, s2; | ||
cin >> s2; | ||
s1 = s2; | ||
|
||
reverse(s2.begin(), s2.end()); | ||
int rez = LCS(s1,s2, s1.size(), s2.size()); | ||
|
||
cout<< abs(s1.size() - rez) << endl; | ||
} | ||
|
||
return 0; | ||
} | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int LCS(string X, string Y, int m, int n){ | ||
int dp[m+1][n+1]; | ||
|
||
for(int i=0;i<=m;i++){ | ||
for(int j=0;j<=n;j++){ | ||
if(i == 0 || j == 0){ | ||
dp[i][j] = 0; | ||
} | ||
else if(X[i - 1] == Y[j - 1]){ | ||
dp[i][j] = dp[i - 1][j - 1] + 1; | ||
} | ||
else{ | ||
dp[i][j] = max(dp[i-1][j], dp[i][j-1]); | ||
} | ||
} | ||
} | ||
//cout << dp[m][n] << endl; | ||
return dp[m][n]; | ||
} | ||
|
||
int main() | ||
{ | ||
//LCS("fft", "tff" , 3, 3); | ||
|
||
int T; | ||
scanf("%d",&T); | ||
|
||
while(T--){ | ||
string s1, s2; | ||
cin >> s2; | ||
s1 = s2; | ||
|
||
reverse(s2.begin(), s2.end()); | ||
int rez = LCS(s1,s2, s1.size(), s2.size()); | ||
|
||
cout<< abs(s1.size() - rez) << endl; | ||
} | ||
|
||
return 0; | ||
} |
Oops, something went wrong.