Skip to content

Commit

Permalink
leetcode025
Browse files Browse the repository at this point in the history
  • Loading branch information
萧天牧 authored and 萧天牧 committed Mar 1, 2017
1 parent c12620f commit 921bb09
Show file tree
Hide file tree
Showing 587 changed files with 12,626 additions and 165 deletions.
Binary file added POJ/.DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions POJ/HDU1166/HDU1166.xcodeproj/project.pbxproj
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
1845C3D61D9CB0D100775FE1 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1845C3D51D9CB0D100775FE1 /* main.cpp */; };
1845C3DE1D9D33B300775FE1 /* test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1845C3DC1D9D33B300775FE1 /* test.cpp */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -25,6 +26,8 @@
/* Begin PBXFileReference section */
1845C3D21D9CB0D100775FE1 /* HDU1166 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = HDU1166; sourceTree = BUILT_PRODUCTS_DIR; };
1845C3D51D9CB0D100775FE1 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
1845C3DC1D9D33B300775FE1 /* test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test.cpp; sourceTree = "<group>"; };
1845C3DD1D9D33B300775FE1 /* test.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = test.hpp; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -58,6 +61,8 @@
isa = PBXGroup;
children = (
1845C3D51D9CB0D100775FE1 /* main.cpp */,
1845C3DC1D9D33B300775FE1 /* test.cpp */,
1845C3DD1D9D33B300775FE1 /* test.hpp */,
);
path = HDU1166;
sourceTree = "<group>";
Expand Down Expand Up @@ -119,6 +124,7 @@
buildActionMask = 2147483647;
files = (
1845C3D61D9CB0D100775FE1 /* main.cpp in Sources */,
1845C3DE1D9D33B300775FE1 /* test.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Empty file.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "HDU1166/main.cpp"
timestampString = "496841730.142807"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "22"
endingLineNumber = "22"
landmarkName = "build(int index, int l, int r)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "HDU1166/main.cpp"
timestampString = "496841730.142807"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "21"
endingLineNumber = "21"
landmarkName = "build(int index, int l, int r)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
45 changes: 45 additions & 0 deletions POJ/HDU1166/HDU1166.xcodeproj/xcuserdata/danache.xcuserdatad/xcschemes/HDU1166.xcscheme
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1845C3D11D9CB0D100775FE1"
BuildableName = "HDU1166"
BlueprintName = "HDU1166"
ReferencedContainer = "container:HDU1166.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
Expand All @@ -13,6 +29,15 @@
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1845C3D11D9CB0D100775FE1"
BuildableName = "HDU1166"
BlueprintName = "HDU1166"
ReferencedContainer = "container:HDU1166.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
Expand All @@ -26,6 +51,16 @@
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1845C3D11D9CB0D100775FE1"
BuildableName = "HDU1166"
BlueprintName = "HDU1166"
ReferencedContainer = "container:HDU1166.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
Expand All @@ -35,6 +70,16 @@
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1845C3D11D9CB0D100775FE1"
BuildableName = "HDU1166"
BlueprintName = "HDU1166"
ReferencedContainer = "container:HDU1166.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
Empty file.
89 changes: 84 additions & 5 deletions POJ/HDU1166/HDU1166/main.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,90 @@
// Created by dan on 16/9/29.
// Copyright © 2016年 dan. All rights reserved.
//

/*
#include <iostream>
#define M 50005
using namespace std;
int sav[M];
int sum[M<<2];
inline void pushUp(int i){
sum[i] = sum[i * 2] + sum[i * 2 + 1];
}
int main(int argc, const char * argv[]) {
// insert code here...
std::cout << "Hello, World!\n";
return 0;
void build(int index, int l, int r){
if (l == r){
sum[index] = sav[l];
return;
}
build(index * 2, l, (l + r) / 2);
build(index * 2 + 1, (l + r) / 2 + 1, r);
pushUp(index);
}
void update(int index, int addnum, int l, int r, int savindex){
if (l == r){
sum[savindex] += addnum;
return;
}
else{
int m = (r + l) / 2;
if (index <= m){
update(index, addnum, l, m, savindex * 2);
}
else
{
update(index, addnum, m + 1, r, savindex * 2 + 1);
}
pushUp(savindex);
}
}
int query(int begin, int end, int l, int r, int index){
if (l > end || r < begin)
return -1;
else if (l >= begin && r <= end){
return sum[index];
}
else{
int m = (r + l) / 2;
int ans=0;
if(begin <= m )
ans += query(begin,end,l, m, index * 2);
if(end > m)
ans += query(begin,end,m + 1, r, index * 2 + 1);
return ans;
}
}
int main()
{
int T, n, a, b;
scanf("%d",&T);
for( int i = 1; i <= T; ++i )
{
printf("Case %d:\n",i);
scanf("%d",&n);
for (int i = 1; i <= n; i++){
scanf("%d",&sav[i]);
}
build(1,1,n);
char op[10];
while( scanf("%s",op) &&op[0]!='E' )
{
scanf("%d %d", &a, &b);
if(op[0] == 'Q')
printf("%d\n",query(a,b,1,n,1));
else if(op[0] == 'S')
update(a,-b,1,n,1);
else
update(a,b,1,n,1);
}
}
return 0;
}
*/
86 changes: 86 additions & 0 deletions POJ/HDU1166/HDU1166/test.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,89 @@
//

#include "test.hpp"
#include <cstring>
#include <iostream>
#define MAXN 50005
using namespace std;
int sav[MAXN];
int sum[MAXN * 4];

void pushUp(int i){
sum[i] = sum[i * 2] + sum[i * 2 + 1];
}

void build(int index, int l, int r){
if (l == r)
{
sum[index] = sav[l];//叶子节点
return;
}
else{
build(index * 2, l , (l + r) / 2); //递归的对他的儿子结点构造,由于是完美二叉树,孩子节点
//为index << 1与 index <<1 | 1,相应的,令 m = (r +l) / 2;
//对应区间为(l, m / 2), (m + 1, r);最后更新父亲节点的值,无论是最小值还是求和
build(index * 2 + 1, (l + r) / 2 + 1, r);
pushUp(index);
}

}

void update(int bianhao, int addnum, int l, int r, int cunchu){
if (l == r)
sum[cunchu] += addnum;
else{
int m = (l + r) / 2;
if (bianhao <= m){//这里的目的是找到bianhao对应的数组位置.
update(bianhao, addnum, l, m, 2 * cunchu);
}
else
update(bianhao, addnum, m + 1, r , 2 * cunchu + 1);
pushUp(cunchu);
}
}

int query(int begin, int end, int l, int r, int index){
if (l >= begin && r <= end){
return sum[index];
}
int m = (l + r) / 2;
int ans = 0;
if (begin <= m){
ans += query(begin, end, l, m, index * 2);
}
if ( m < end ){
ans += query(begin, end, m + 1, r, index * 2 + 1);
}
return ans;
}

int main()
{
int T, n, a, b;
scanf("%d",&T);
for( int i = 1; i <= T; ++i )
{
printf("Case %d:\n",i);
scanf("%d",&n);
for (int i = 1; i <= n; i++){
scanf("%d", &sav[i]);
}
build(1,1, n);

char op[10];

while( scanf("%s",op) &&op[0]!='E' )
{

scanf("%d %d", &a, &b);
if(op[0] == 'Q')
printf("%d\n",query(1,n,a,b,1));
else if(op[0] == 'S')
update(a,-b,1,n,1);
else
update(a,b,1,n,1);

}
}
return 0;
}
Empty file modified POJ/HDU1166/HDU1166/test.hpp
100644 → 100755
Empty file.
Empty file modified POJ/POJ1003/POJ1003.xcodeproj/project.pbxproj
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified POJ/POJ1003/POJ1003/main.cpp
100644 → 100755
Empty file.
Empty file modified POJ/POJ1005/POJ1005.xcodeproj/project.pbxproj
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified POJ/POJ1005/POJ1005/main.cpp
100644 → 100755
Empty file.
Empty file modified POJ/POJ1006/POJ1006.xcodeproj/project.pbxproj
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified POJ/POJ1006/POJ1006/main.cpp
100644 → 100755
Empty file.
Empty file modified POJ/POJ1007/POJ1007.xcodeproj/project.pbxproj
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified POJ/POJ1007/POJ1007/main.cpp
100644 → 100755
Empty file.
Empty file modified POJ/POJ1007/POJ1007/test.input
100644 → 100755
Empty file.
Empty file modified POJ/POJ1012/POJ1012.xcodeproj/project.pbxproj
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified POJ/POJ1012/POJ1012/main.cpp
100644 → 100755
Empty file.
Empty file modified POJ/POJ1013/POJ1013.xcodeproj/project.pbxproj
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified POJ/POJ1013/POJ1013/main.cpp
100644 → 100755
Empty file.
Empty file modified POJ/POJ1019/POJ1019.xcodeproj/project.pbxproj
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified POJ/POJ1019/POJ1019/main.cpp
100644 → 100755
Empty file.
Empty file modified POJ/POJ1028/POJ1028.xcodeproj/project.pbxproj
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified POJ/POJ1028/POJ1028/main.cpp
100644 → 100755
Empty file.
Empty file modified POJ/POJ1050/POJ1050.xcodeproj/project.pbxproj
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified POJ/POJ1050/POJ1050/main.cpp
100644 → 100755
Empty file.
Empty file modified POJ/POJ1068/POJ1068.xcodeproj/project.pbxproj
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified POJ/POJ1068/POJ1068/main.cpp
100644 → 100755
Empty file.
Empty file modified POJ/POJ1080/POJ1080.xcodeproj/project.pbxproj
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified POJ/POJ1080/POJ1080/main.cpp
100644 → 100755
Empty file.
Empty file modified POJ/POJ1182/POJ1182.xcodeproj/project.pbxproj
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified POJ/POJ1182/POJ1182/main.cpp
100644 → 100755
Empty file.
Empty file modified POJ/POJ1298/POJ1298.xcodeproj/project.pbxproj
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified POJ/POJ1298/POJ1298/main.cpp
100644 → 100755
Empty file.
Empty file modified POJ/POJ1308/POJ1308.xcodeproj/project.pbxproj
100644 → 100755
Empty file.
Empty file.
Binary file not shown.
Loading

0 comments on commit 921bb09

Please sign in to comment.