Generated
+9
@@ -7,7 +7,16 @@
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="FixPatternMiner" />
|
||||
<module name="gen.jdt" />
|
||||
<module name="gen.srcml" />
|
||||
<module name="client.diff" />
|
||||
<module name="fixminer_source" />
|
||||
<module name="client" />
|
||||
<module name="core" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
<bytecodeTargetLevel>
|
||||
<module name="simple-utils" target="1.8" />
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+8
-1
@@ -1,6 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with NO BOM">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/../gumtree/client.diff/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/../gumtree/client.diff/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/../gumtree/client/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/../gumtree/core/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/../gumtree/gen.jdt/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/../gumtree/gen.srcml/src/main/java" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+2
-1
@@ -5,10 +5,11 @@
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
<option value="$PROJECT_DIR$/../gumtree/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+1
@@ -2,5 +2,6 @@
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/../gumtree" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+208
-660
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resource" type="java-resource" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.javatuples:javatuples:1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: me.tongfei:progressbar:0.8.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jline:jline:3.13.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jline:jline-terminal-jansi:3.13.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.fusesource.jansi:jansi:1.18" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jline:jline-terminal:3.13.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.typesafe.akka:akka-actor_2.11:2.4.17" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.scala-lang:scala-library:2.11.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.typesafe:config:1.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.scala-lang.modules:scala-java8-compat_2.11:0.7.0" level="project" />
|
||||
<orderEntry type="module" module-name="core" />
|
||||
<orderEntry type="library" name="Maven: com.github.mpkorstanje:simmetrics-core:3.0.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:18.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.sf.trove4j:trove4j:3.0.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.3" level="project" />
|
||||
<orderEntry type="module" module-name="gen.jdt" />
|
||||
<orderEntry type="library" name="Maven: edu.lu.uni:simple-utils:0.0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi:3.12" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml:3.12" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:3.12" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:2.6.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: stax:stax-api:1.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.sourceforge.jexcelapi:jxl:2.6.12" level="project" />
|
||||
<orderEntry type="library" name="Maven: log4j:log4j:1.2.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.core:runtime:3.10.0-v20140318-2214" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse:osgi:3.10.0-v20140606-1445" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.equinox:common:3.6.200-v20130402-1505" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.core:jobs:3.6.0-v20140424-0053" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.equinox:registry:3.5.400-v20140428-1507" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.equinox:preferences:3.5.200-v20140224-1527" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.core:contenttype:3.4.200-v20140207-1251" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.equinox:app:1.3.200-v20130910-1609" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.birt.runtime:org.eclipse.core.resources:3.10.0.v20150423-0755" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.tycho:org.eclipse.jdt.core:3.12.2.v20161117-1814" level="project" />
|
||||
<orderEntry type="module" module-name="gen.srcml" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: redis.clients:jedis:2.8.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-text:1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.4" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -12,9 +12,14 @@
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<akka.version>2.4.11</akka.version>
|
||||
<akka.version>2.4.17</akka.version>
|
||||
<logback.version>1.1.2</logback.version>
|
||||
<slf4j-api.version>1.7.7</slf4j-api.version>
|
||||
<gumtree.version>2.0.0-SNAPSHOT</gumtree.version>
|
||||
<junit.version>4.12</junit.version>
|
||||
<redis.version>2.8.1</redis.version>
|
||||
<commons.version>1.3</commons.version>
|
||||
<commons-io.version>2.4</commons-io.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -25,11 +30,11 @@
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>edu.lu.uni</groupId>-->
|
||||
<!--<artifactId>simple-utils</artifactId>-->
|
||||
<!--<version>0.0.1-SNAPSHOT</version>-->
|
||||
<!--</dependency>-->
|
||||
<dependency>
|
||||
<groupId>me.tongfei</groupId>
|
||||
<artifactId>progressbar</artifactId>
|
||||
<version>0.8.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- akka -->
|
||||
<dependency>
|
||||
@@ -41,13 +46,22 @@
|
||||
<dependency>
|
||||
<groupId>com.github.gumtreediff</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
<version>${gumtree.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.gumtreediff</groupId>
|
||||
<artifactId>gen.jdt</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
<version>${gumtree.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.gumtreediff</groupId>
|
||||
<artifactId>gen.srcml</artifactId>
|
||||
<scope>compile</scope>
|
||||
<version>${gumtree.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- SLF4J - API -->
|
||||
@@ -69,92 +83,35 @@
|
||||
<version>${logback.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!--<dependency>-->
|
||||
<!--<groupId>edu.lu.uni.serval</groupId>-->
|
||||
<!--<artifactId>GitTraveller</artifactId>-->
|
||||
<!--<version>0.0.1-SNAPSHOT</version>-->
|
||||
<!--</dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
<version>${junit.version}</version>
|
||||
<!-- <scope>test</scope>-->
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>2.8.1</version>
|
||||
<version>${redis.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-text -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-text</artifactId>
|
||||
<version>1.3</version>
|
||||
<version>${commons.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.rabbitmq</groupId>
|
||||
<artifactId>amqp-client</artifactId>
|
||||
<version>4.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.11</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-core -->
|
||||
<dependency>
|
||||
<groupId>org.apache.lucene</groupId>
|
||||
<artifactId>lucene-core</artifactId>
|
||||
<version>4.8.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-analyzers-common -->
|
||||
<dependency>
|
||||
<groupId>org.apache.lucene</groupId>
|
||||
<artifactId>lucene-analyzers-common</artifactId>
|
||||
<version>4.8.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-math3 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-math3</artifactId>
|
||||
<version>3.6.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream -->
|
||||
<dependency>
|
||||
<groupId>com.thoughtworks.xstream</groupId>
|
||||
<artifactId>xstream</artifactId>
|
||||
<version>1.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.4</version>
|
||||
<version>${commons-io.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson</artifactId>
|
||||
<version>3.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-util</artifactId>
|
||||
<version>9.4.4.v20170414</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.esotericsoftware</groupId>
|
||||
<artifactId>kryo</artifactId>
|
||||
<version>4.0.2</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
@@ -184,7 +141,7 @@
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>
|
||||
<!--edu.lu.uni.serval.fixminer.akka.compare.CompareTrees-->
|
||||
<!--edu.lu.uni.serval.fixminer.jobs.CompareTrees-->
|
||||
edu.lu.uni.serval.fixminer.Launcher
|
||||
</mainClass>
|
||||
</manifest>
|
||||
@@ -201,6 +158,6 @@
|
||||
</project>
|
||||
|
||||
<!--edu.lu.uni.serval.fixminer.Launcher
|
||||
edu.lu.uni.serval.fixminer.akka.compare.CompareTrees
|
||||
edu.lu.uni.serval.fixminer.jobs.CompareTrees
|
||||
edu.lu.uni.serval.utils.ClusterToPattern
|
||||
-->
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package edu.lu.uni.serval.fixminer;
|
||||
|
||||
import edu.lu.uni.serval.fixminer.akka.compare.CompareTrees;
|
||||
import edu.lu.uni.serval.fixminer.jobs.CompareTrees;
|
||||
import edu.lu.uni.serval.fixminer.jobs.EnhancedASTDiff;
|
||||
import edu.lu.uni.serval.utils.ClusterToPattern;
|
||||
import org.slf4j.Logger;
|
||||
@@ -8,6 +8,8 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
@@ -22,45 +24,59 @@ public class Launcher {
|
||||
|
||||
Properties appProps = new Properties();
|
||||
|
||||
// String appConfigPath = "/Users/anilkoyuncu/bugStudy/release/code/app.properties";
|
||||
String appConfigPath = args[0];
|
||||
String hostname = "Unknown";
|
||||
try
|
||||
{
|
||||
InetAddress addr;
|
||||
addr = InetAddress.getLocalHost();
|
||||
hostname = addr.getHostName();
|
||||
}
|
||||
catch (UnknownHostException ex)
|
||||
{
|
||||
System.out.println("Hostname can not be resolved");
|
||||
}
|
||||
String appConfigPath;
|
||||
if (hostname.equals("Unknown")){
|
||||
appConfigPath = "src/main/resource/app.properties";
|
||||
}
|
||||
else{
|
||||
appConfigPath = "src/main/resource/"+hostname+".app.properties";
|
||||
}
|
||||
// String appConfigPath = args[0];
|
||||
appProps.load(new FileInputStream(appConfigPath));
|
||||
|
||||
String portInner = appProps.getProperty("portInner","6380");
|
||||
String numOfWorkers = appProps.getProperty("numOfWorkers", "10");
|
||||
String portDumps = appProps.getProperty("portDumps","6399");
|
||||
String pjName = appProps.getProperty("pjName","allDataset");
|
||||
String actionType = appProps.getProperty("actionType","ALL");
|
||||
String eDiffTimeout = appProps.getProperty("eDiffTimeout","900");
|
||||
String parallelism = appProps.getProperty("parallelism","FORKJOIN");
|
||||
String projectType = appProps.getProperty("projectType","java");
|
||||
|
||||
String hunkLimit = appProps.getProperty("hunkLimit","10");
|
||||
String patchSize = appProps.getProperty("patchSize","50");
|
||||
String projectL = appProps.getProperty("projectList","");
|
||||
String[] projectList = projectL.split(",");
|
||||
String input = appProps.getProperty("inputPath","FORKJOIN");
|
||||
String redisPath = appProps.getProperty("redisPath","FORKJOIN");
|
||||
String srcMLPath = appProps.getProperty("srcMLPath","FORKJOIN");
|
||||
|
||||
String parameter = args[2];
|
||||
String jobType = args[1];
|
||||
// String parameter = args[2];
|
||||
String parameter = "L1";
|
||||
// String jobType = args[1];
|
||||
// String jobType = "RICHEDITSCRIPT";
|
||||
String jobType = "COMPARE";
|
||||
|
||||
// String parameters = String.format("\nportInner %s " +
|
||||
// "\nnumOfWorkers %s " +
|
||||
// "\njobType %s \nport %s " +
|
||||
// "\npythonPath %s \ndatasetPath %s" +
|
||||
// "\npjName %s \nactionType %s \nthreshold %s \ncursor %s \neDiffTimeout %s \nisBigPair %s \nparallelism %s"
|
||||
// , portInner, numOfWorkers, jobType, portDumps, pythonPath,datasetPath,pjName,actionType,threshold,cursor,eDiffTimeout,isBig,parallelism);
|
||||
//
|
||||
// log.info(parameters);
|
||||
|
||||
mainLaunch(portInner, numOfWorkers, jobType, portDumps, pjName,actionType,eDiffTimeout,parallelism,input,redisPath,parameter);
|
||||
mainLaunch( numOfWorkers, jobType, portDumps,projectType,input,redisPath,parameter, srcMLPath,hunkLimit,projectList,patchSize);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void mainLaunch(String portInner, String numOfWorkers, String jobType, String portDumps, String pjName, String actionType, String eDiffTimeout, String parallelism,String input, String redisPath,String parameter){
|
||||
public static void mainLaunch(String numOfWorkers, String jobType, String portDumps, String projectType, String input, String redisPath,String parameter,String srcMLPath,String hunkLimit,String[] projectList,String patchSize){
|
||||
|
||||
|
||||
String dbDir;
|
||||
String dumpsName;
|
||||
String gumInput;
|
||||
|
||||
dumpsName = "dumps-"+pjName+".rdb";
|
||||
dumpsName = "dumps-"+projectType+".rdb";
|
||||
|
||||
gumInput = input;
|
||||
dbDir = redisPath;
|
||||
@@ -69,7 +85,7 @@ public class Launcher {
|
||||
try {
|
||||
switch (jobType) {
|
||||
case "RICHEDITSCRIPT":
|
||||
EnhancedASTDiff.main(gumInput, numOfWorkers, pjName, eDiffTimeout,parallelism,portDumps, dbDir, actionType+dumpsName);
|
||||
EnhancedASTDiff.main(gumInput, portDumps, dbDir, dumpsName, srcMLPath,parameter,hunkLimit,projectList,patchSize,projectType);
|
||||
break;
|
||||
|
||||
case "COMPARE":
|
||||
@@ -77,7 +93,8 @@ public class Launcher {
|
||||
String compareDBName;
|
||||
switch (parameter){
|
||||
case "L1":
|
||||
job = "shape";
|
||||
// job = "shape";
|
||||
job = "single";
|
||||
compareDBName = "clusterl0-gumInputALL.rdb";
|
||||
break;
|
||||
case "L2":
|
||||
@@ -93,10 +110,10 @@ public class Launcher {
|
||||
}
|
||||
|
||||
|
||||
CompareTrees.main(redisPath, portInner,portDumps,actionType+dumpsName,compareDBName, job);
|
||||
CompareTrees.main(redisPath, portDumps,dumpsName, job,numOfWorkers);
|
||||
break;
|
||||
case "PATTERN":
|
||||
ClusterToPattern.main(portDumps,redisPath, actionType+dumpsName, parameter);
|
||||
ClusterToPattern.main(portDumps,redisPath, dumpsName, parameter);
|
||||
break;
|
||||
default:
|
||||
throw new Error("unknown Job");
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
package edu.lu.uni.serval.fixminer.akka.compare;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.ScanParams;
|
||||
import redis.clients.jedis.ScanResult;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Created by anilkoyuncu on 12/09/2018.
|
||||
*/
|
||||
public class AkkaTreeParser {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(AkkaTreeParser.class);
|
||||
|
||||
public static List<String> getMessages(JedisPool innerPool, int cursor){
|
||||
|
||||
|
||||
ScanResult<String> scan;
|
||||
|
||||
try (Jedis inner = innerPool.getResource()) {
|
||||
while (!inner.ping().equals("PONG")){
|
||||
log.info("wait");
|
||||
}
|
||||
ScanParams sc = new ScanParams();
|
||||
//150000000
|
||||
log.info("Scanning ");
|
||||
sc.count(cursor);
|
||||
|
||||
sc.match("*");
|
||||
// sc.match("pair_[0-9]*");
|
||||
|
||||
scan = inner.scan("0", sc);
|
||||
|
||||
int size = scan.getResult().size();
|
||||
log.info("Scanned " + String.valueOf(size));
|
||||
|
||||
}
|
||||
List<String> result = scan.getResult();
|
||||
log.info("Getting results");
|
||||
return result;
|
||||
}
|
||||
|
||||
public static HashMap<String, String> filenames(JedisPool innerPool){
|
||||
|
||||
|
||||
HashMap<String, String> fileMap =new HashMap<String, String>();
|
||||
|
||||
try (Jedis inner = innerPool.getResource()) {
|
||||
while (!inner.ping().equals("PONG")){
|
||||
log.info("wait");
|
||||
}
|
||||
|
||||
inner.select(1);
|
||||
Map<String, String> filenames = inner.hgetAll("filenames");
|
||||
|
||||
|
||||
for (Map.Entry<String, String> stringStringEntry : filenames.entrySet().stream().collect(Collectors.toList())) {
|
||||
fileMap.put(stringStringEntry.getKey(),stringStringEntry.getValue());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
log.info("Getting results");
|
||||
return fileMap;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,269 +0,0 @@
|
||||
package edu.lu.uni.serval.fixminer.akka.compare;
|
||||
|
||||
import com.github.gumtreediff.tree.ITree;
|
||||
import edu.lu.uni.serval.fixminer.akka.ediff.HierarchicalActionSet;
|
||||
import edu.lu.uni.serval.utils.CallShell;
|
||||
import edu.lu.uni.serval.utils.EDiffHelper;
|
||||
import edu.lu.uni.serval.utils.PoolBuilder;
|
||||
import org.apache.commons.text.similarity.JaroWinklerDistance;
|
||||
import org.javatuples.Pair;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Created by anilkoyuncu on 03/04/2018.
|
||||
*/
|
||||
public class CompareTrees {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(CompareTrees.class);
|
||||
|
||||
|
||||
public static void main(String redisPath, String portInner, String portDumps, String dumpsName, String compareDBName, String job) throws Exception {
|
||||
|
||||
// shape /Users/anil.koyuncu/projects/test/fixminer-core/python/data/redis ALLdumps-gumInput.rdb clusterl0-gumInputALL.rdb /Users/anil.koyuncu/projects/test/fixminer-core/python/data/richEditScript
|
||||
|
||||
// String portInner = "6380";
|
||||
String port = portDumps; //"6399";
|
||||
CallShell cs = new CallShell();
|
||||
String cmd = "bash "+redisPath + "/" + "startServer.sh" +" %s %s %s";
|
||||
cmd = String.format(cmd, redisPath,dumpsName,Integer.valueOf(port));
|
||||
log.info(cmd);
|
||||
cs.runShell(cmd, port);
|
||||
|
||||
String cmdInner = "bash "+redisPath + "/" + "startServer.sh" +" %s %s %s";
|
||||
cmdInner = String.format(cmdInner, redisPath,compareDBName,Integer.valueOf(portInner));
|
||||
log.info(cmdInner);
|
||||
cs.runShell(cmdInner, portInner);
|
||||
|
||||
String numOfWorkers = "100000000";//args[4];
|
||||
String host = "localhost";//args[5];
|
||||
// -Djava.util.concurrent.ForkJoinPool.common.parallelism=256
|
||||
|
||||
final JedisPool innerPool = new JedisPool(PoolBuilder.getPoolConfig(), host,Integer.valueOf(portInner),20000000);
|
||||
|
||||
final JedisPool outerPool = new JedisPool(PoolBuilder.getPoolConfig(), host,Integer.valueOf(port),20000000);
|
||||
|
||||
List<String> listOfPairs = AkkaTreeParser.getMessages(innerPool,Integer.valueOf(numOfWorkers));
|
||||
HashMap<String, String> filenames = AkkaTreeParser.filenames(innerPool);
|
||||
|
||||
|
||||
ArrayList<String> samePairs = new ArrayList<>();
|
||||
ArrayList<String> errorPairs = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
listOfPairs.stream().parallel().forEach(m->coreCompare(m, job,innerPool, samePairs,errorPairs,filenames,outerPool));
|
||||
|
||||
try (Jedis jedis = innerPool.getResource()) {
|
||||
|
||||
jedis.select(0);
|
||||
jedis.flushDB();
|
||||
for (String errorPair : errorPairs) {
|
||||
jedis.hset(errorPair, "0", "1");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
log.info("End process");
|
||||
}
|
||||
public static void coreCompare(String pairName, String treeType,JedisPool innerPool,ArrayList<String> samePairs,ArrayList<String> errorPairs, HashMap<String, String> filenames,JedisPool outerPool ) {
|
||||
|
||||
// if (samePairs.size() % 1000 == 0) {
|
||||
// log.info("Same pairs size "+samePairs.size());
|
||||
// }
|
||||
|
||||
ITree oldTree = null;
|
||||
ITree newTree = null;
|
||||
Pair<ITree, HierarchicalActionSet> oldPair = null;
|
||||
Pair<ITree, HierarchicalActionSet> newPair = null;
|
||||
String matchKey = null;
|
||||
|
||||
try {
|
||||
|
||||
String[] split = pairName.split("_");
|
||||
|
||||
|
||||
String i = split[1];
|
||||
String j = split[2];
|
||||
String keyName = split[0];
|
||||
matchKey = keyName + "_" + (String.valueOf(i)) + "_" + String.valueOf(j);
|
||||
// jedis.select(0);
|
||||
// Set<String> keys = jedis.keys(matchKey);
|
||||
// if (keys.size() > 0) {
|
||||
// jedis.del(matchKey);
|
||||
// } else {
|
||||
// return;
|
||||
// }
|
||||
// jedis.srem("pairs",matchKey);
|
||||
// JedisPool outerPool = null;
|
||||
switch (treeType) {
|
||||
case "shape":
|
||||
oldTree = EDiffHelper.getShapes(keyName, i, outerPool,filenames);
|
||||
newTree = EDiffHelper.getShapes(keyName, j, outerPool,filenames);
|
||||
break;
|
||||
case "action":
|
||||
|
||||
oldPair = EDiffHelper.getActions(keyName, i, outerPool, filenames);
|
||||
newPair = EDiffHelper.getActions(keyName, j, outerPool, filenames);
|
||||
oldTree = oldPair.getValue0();
|
||||
newTree = newPair.getValue0();
|
||||
|
||||
|
||||
break;
|
||||
case "token":
|
||||
oldTree = EDiffHelper.getTokens(keyName, i, outerPool, filenames);
|
||||
newTree = EDiffHelper.getTokens(keyName, j, outerPool, filenames);
|
||||
|
||||
String oldTokens = EDiffHelper.getNames2(oldTree);
|
||||
String newTokens = EDiffHelper.getNames2(newTree);
|
||||
|
||||
JaroWinklerDistance jwd = new JaroWinklerDistance();
|
||||
|
||||
|
||||
Double overallSimi = Double.valueOf(0);
|
||||
|
||||
if (!(oldTokens.trim().isEmpty() || newTokens.trim().isEmpty())) {
|
||||
overallSimi = jwd.apply(oldTokens, newTokens);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int retval = Double.compare(overallSimi, Double.valueOf(1));
|
||||
|
||||
if (retval >= 0) {
|
||||
String result = i + "," + j + "," + String.join(",", oldTokens);
|
||||
// jedis.select(2);
|
||||
// jedis.set(matchKey, result);
|
||||
try (Jedis jedis = innerPool.getResource()) {
|
||||
// jedis.del(matchKey);
|
||||
jedis.select(2);
|
||||
jedis.set(matchKey, result);
|
||||
}
|
||||
// samePairs.add(matchKey);
|
||||
// try (Jedis jedis = innerPool.getResource()) {
|
||||
//// jedis.del(matchKey);
|
||||
// jedis.select(2);
|
||||
// jedis.set(matchKey, result);
|
||||
// }
|
||||
}
|
||||
// jedis.select(0);
|
||||
//// jedis.srem("pairs",matchKey);
|
||||
// jedis.del(matchKey);
|
||||
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(oldTree.toStaticHashString().equals(newTree.toStaticHashString())){
|
||||
String editDistance = "0";
|
||||
String result = i + "," + j + "," + editDistance;
|
||||
if (editDistance.equals("0")) {
|
||||
|
||||
if (treeType.equals("action")) {
|
||||
HierarchicalActionSet oldProject = oldPair.getValue1();
|
||||
HierarchicalActionSet newProject = newPair.getValue1();
|
||||
|
||||
oldTree = EDiffHelper.getTargets(oldProject);
|
||||
newTree = EDiffHelper.getTargets(newProject);
|
||||
if (oldTree.toStaticHashString().equals(newTree.toStaticHashString())) {
|
||||
try (Jedis jedis = innerPool.getResource()) {
|
||||
// jedis.del(matchKey);
|
||||
jedis.select(2);
|
||||
jedis.set(matchKey, result);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try (Jedis jedis = innerPool.getResource()) {
|
||||
// jedis.del(matchKey);
|
||||
jedis.select(2);
|
||||
jedis.set(matchKey, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// if(oldTree.toString().equals(newTree.toString())) {
|
||||
// Matcher m = Matchers.getInstance().getMatcher(oldTree, newTree);
|
||||
// m.match();
|
||||
//
|
||||
//
|
||||
// ActionGenerator ag = new ActionGenerator(oldTree, newTree, m.getMappings());
|
||||
// ag.generate();
|
||||
// List<Action> actions = ag.getActions();
|
||||
//
|
||||
//
|
||||
// String editDistance;
|
||||
//
|
||||
// editDistance = String.valueOf(actions.size());
|
||||
// String result = i + "," + j + "," + editDistance;
|
||||
//
|
||||
//
|
||||
// if (editDistance.equals("0")) {
|
||||
//
|
||||
// if (treeType.equals("action")) {
|
||||
//
|
||||
// HierarchicalActionSet oldProject = oldPair.getValue1();
|
||||
// HierarchicalActionSet newProject = newPair.getValue1();
|
||||
//
|
||||
// oldTree = EDiffHelper.getTargets(oldProject);
|
||||
// newTree = EDiffHelper.getTargets(newProject);
|
||||
//
|
||||
// if(oldTree.toString().equals(newTree.toString())) {
|
||||
// m = Matchers.getInstance().getMatcher(oldTree, newTree);
|
||||
// m.match();
|
||||
//
|
||||
//
|
||||
// ag = new ActionGenerator(oldTree, newTree, m.getMappings());
|
||||
// ag.generate();
|
||||
// actions = ag.getActions();
|
||||
//
|
||||
// editDistance = String.valueOf(actions.size());
|
||||
//
|
||||
// if (editDistance.equals("0")) {
|
||||
// try (Jedis jedis = innerPool.getResource()) {
|
||||
// jedis.del(matchKey);
|
||||
// jedis.select(2);
|
||||
// jedis.set(matchKey, result);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// } else {
|
||||
// try (Jedis jedis = innerPool.getResource()) {
|
||||
// jedis.del(matchKey);
|
||||
// jedis.select(2);
|
||||
// jedis.set(matchKey, result);
|
||||
// }
|
||||
//// jedis.select(2);
|
||||
//// jedis.set(matchKey, result);
|
||||
//// samePairs.add(matchKey);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
} catch (Exception e) {
|
||||
errorPairs.add(matchKey);
|
||||
// jedis.select(0);
|
||||
//// jedis.srem("pairs",matchKey);
|
||||
//
|
||||
// jedis.hset(matchKey, "0", "1");
|
||||
|
||||
log.debug("{} not comparable", pairName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
package edu.lu.uni.serval.fixminer.akka.ediff;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
import com.esotericsoftware.kryo.Kryo;
|
||||
import com.esotericsoftware.kryo.io.Input;
|
||||
import com.esotericsoftware.kryo.io.Output;
|
||||
import com.esotericsoftware.kryo.pool.KryoFactory;
|
||||
import com.esotericsoftware.kryo.pool.KryoPool;
|
||||
import org.objenesis.strategy.SerializingInstantiatorStrategy;
|
||||
|
||||
|
||||
public class DefaultKryoContext implements KryoContext{
|
||||
|
||||
private static final int DEFAULT_BUFFER = 1024 * 100;
|
||||
|
||||
private KryoPool pool;
|
||||
|
||||
public static KryoContext newKryoContextFactory()
|
||||
{
|
||||
return new DefaultKryoContext();
|
||||
}
|
||||
|
||||
private DefaultKryoContext()
|
||||
{
|
||||
KryoFactory factory = new KryoFactoryImpl();
|
||||
|
||||
pool = new KryoPool.Builder(factory).softReferences().build();
|
||||
}
|
||||
|
||||
private static class KryoFactoryImpl implements KryoFactory
|
||||
{
|
||||
@Override
|
||||
public Kryo create() {
|
||||
Kryo kryo = new Kryo();
|
||||
kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new SerializingInstantiatorStrategy()));
|
||||
return kryo;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public byte[] serialze(Object obj)
|
||||
{
|
||||
return serialze(obj, DEFAULT_BUFFER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] serialze(Object obj, int bufferSize)
|
||||
{
|
||||
ByteArrayOutputStream base = new ByteArrayOutputStream();
|
||||
Output output = new Output(base, bufferSize);
|
||||
|
||||
Kryo kryo = pool.borrow();
|
||||
|
||||
kryo.writeObject(output, obj);
|
||||
|
||||
output.flush();
|
||||
byte[] serialized = base.toByteArray();
|
||||
output.close();
|
||||
|
||||
// byte[] serialized = output.toBytes();
|
||||
|
||||
pool.release(kryo);
|
||||
|
||||
return serialized;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object deserialze(Class clazz, byte[] serialized)
|
||||
{
|
||||
Object obj;
|
||||
|
||||
Kryo kryo = pool.borrow();
|
||||
|
||||
Input input = new Input(serialized);
|
||||
obj = kryo.readObject(input, clazz);
|
||||
|
||||
pool.release(kryo);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
package edu.lu.uni.serval.fixminer.akka.ediff;
|
||||
|
||||
import edu.lu.uni.serval.utils.EDiffHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parse fix violations with GumTree in terms of multiple statements.
|
||||
*
|
||||
* @author kui.liu
|
||||
*
|
||||
*/
|
||||
public class EDiffHunkParser extends EDiffParser {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(EDiffHunkParser.class);
|
||||
@Override
|
||||
public void parseFixPatterns(File prevFile, File revFile, File diffentryFile, String project, JedisPool innerPool) {
|
||||
List<HierarchicalActionSet> actionSets = parseChangedSourceCodeWithGumTree2(prevFile, revFile);
|
||||
if (actionSets.size() != 0) {
|
||||
|
||||
boolean processActionSet = true;
|
||||
|
||||
int hunkSet = 0;
|
||||
if(processActionSet){
|
||||
for (HierarchicalActionSet actionSet : actionSets) {
|
||||
FileOutputStream f = null;
|
||||
|
||||
try {
|
||||
|
||||
String astNodeType = actionSet.getAstNodeType();
|
||||
actionSet.toString();
|
||||
int size = actionSet.getActionSize();
|
||||
|
||||
String datasetName = project;
|
||||
String[] split1 = diffentryFile.getParent().split(datasetName);
|
||||
String root = split1[0];
|
||||
String pj = split1[1].split("/")[1];
|
||||
|
||||
|
||||
String key = astNodeType+"/"+String.valueOf(size)+"/" + pj +"_" + diffentryFile.getName() + "_" + String.valueOf(hunkSet);
|
||||
|
||||
try (Jedis inner = innerPool.getResource()) {
|
||||
|
||||
inner.hset("dump".getBytes(),key.getBytes(),EDiffHelper.kryoSerialize(actionSet));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("error",e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
hunkSet++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package edu.lu.uni.serval.fixminer.akka.ediff;
|
||||
|
||||
import com.github.gumtreediff.actions.model.Action;
|
||||
import edu.lu.uni.serval.gumtree.GumTreeComparer;
|
||||
import edu.lu.uni.serval.utils.ListSorter;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Parse fix patterns with GumTree.
|
||||
*
|
||||
* @author kui.liu
|
||||
*
|
||||
*/
|
||||
public class EDiffParser extends Parser {
|
||||
|
||||
/*
|
||||
* ResultType:
|
||||
* 0: normal GumTree results.
|
||||
* 1: null GumTree result.
|
||||
* 2: No source code changes.
|
||||
* 3: No Statement Change.
|
||||
* 4: useless violations
|
||||
*/
|
||||
public int resultType = 0;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Regroup GumTree results without remove the modification of variable names.
|
||||
*
|
||||
* @param prevFile
|
||||
* @param revFile
|
||||
* @return
|
||||
*/
|
||||
protected List<HierarchicalActionSet> parseChangedSourceCodeWithGumTree2(File prevFile, File revFile) {
|
||||
List<HierarchicalActionSet> actionSets = new ArrayList<>();
|
||||
// GumTree results
|
||||
List<Action> gumTreeResults = new GumTreeComparer().compareTwoFilesWithGumTree(prevFile, revFile);
|
||||
if (gumTreeResults == null) {
|
||||
this.resultType = 1;
|
||||
return null;
|
||||
} else if (gumTreeResults.size() == 0){
|
||||
this.resultType = 2;
|
||||
return actionSets;
|
||||
} else {
|
||||
// Regroup GumTre results.
|
||||
List<HierarchicalActionSet> allActionSets = new HierarchicalRegrouper().regroupGumTreeResults(gumTreeResults);
|
||||
|
||||
|
||||
ListSorter<HierarchicalActionSet> sorter = new ListSorter<>(allActionSets);
|
||||
actionSets = sorter.sortAscending();
|
||||
|
||||
if (actionSets.size() == 0) {
|
||||
this.resultType = 3;
|
||||
}
|
||||
|
||||
return actionSets;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseFixPatterns(File prevFile, File revFile, File diffEntryFile, String project, JedisPool innerPool) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package edu.lu.uni.serval.fixminer.akka.ediff;
|
||||
|
||||
public interface KryoContext {
|
||||
|
||||
byte[] serialze(Object obj);
|
||||
|
||||
byte[] serialze(Object obj, int bufferSize);
|
||||
|
||||
Object deserialze(Class clazz, byte[] serialized);
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package edu.lu.uni.serval.fixminer.akka.ediff;
|
||||
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class RunnableParser implements Runnable {
|
||||
|
||||
private File prevFile;
|
||||
private File revFile;
|
||||
private File diffentryFile;
|
||||
private Parser parser;
|
||||
private String project;
|
||||
private JedisPool pool;
|
||||
|
||||
public RunnableParser(File prevFile, File revFile, File diffentryFile, Parser parser) {
|
||||
this.prevFile = prevFile;
|
||||
this.revFile = revFile;
|
||||
this.diffentryFile = diffentryFile;
|
||||
this.parser = parser;
|
||||
}
|
||||
|
||||
public RunnableParser(File prevFile, File revFile, File diffentryFile, Parser parser, String project, JedisPool innerPool) {
|
||||
this.prevFile = prevFile;
|
||||
this.revFile = revFile;
|
||||
this.diffentryFile = diffentryFile;
|
||||
this.parser = parser;
|
||||
this.project = project;
|
||||
this.pool = innerPool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
parser.parseFixPatterns(prevFile, revFile, diffentryFile,project,pool);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package edu.lu.uni.serval.fixminer.akka.ediff;
|
||||
package edu.lu.uni.serval.fixminer.ediff;
|
||||
|
||||
import akka.actor.ActorRef;
|
||||
import akka.actor.Props;
|
||||
@@ -54,7 +54,7 @@ public class EDiffActor extends UntypedActor {
|
||||
int toIndex = (i + 1) * average + counter;
|
||||
|
||||
List<MessageFile> filesOfWorkers = files.subList(fromIndex, toIndex);
|
||||
final EDiffMessage workMsg = new EDiffMessage(i + 1, filesOfWorkers,((EDiffMessage) message).getSECONDS_TO_WAIT(),((EDiffMessage) message).getInnerPool());
|
||||
final EDiffMessage workMsg = new EDiffMessage(i + 1, filesOfWorkers,((EDiffMessage) message).getSECONDS_TO_WAIT(),((EDiffMessage) message).getInnerPool(),((EDiffMessage) message).getSrcMLPath(),((EDiffMessage) message).getRootType());
|
||||
mineRouter.tell(workMsg, getSelf());
|
||||
logger.info("Assign {} task to worker #" + (i + 1) ,filesOfWorkers.size());
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package edu.lu.uni.serval.fixminer.ediff;
|
||||
|
||||
import com.github.gumtreediff.tree.ITree;
|
||||
import edu.lu.uni.serval.utils.EDiffHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parse fix violations with GumTree in terms of multiple statements.
|
||||
*
|
||||
* @author kui.liu
|
||||
*
|
||||
*/
|
||||
public class EDiffHunkParser extends EDiffParser {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(EDiffHunkParser.class);
|
||||
@Override
|
||||
public void parseFixPatterns(File prevFile, File revFile, File diffentryFile, String project, JedisPool innerPool,String srcMLPath,String hunkLimit,boolean isJava) {
|
||||
|
||||
String datasetName = project;
|
||||
String[] split1 = diffentryFile.getParent().split(datasetName);
|
||||
String root = split1[0];
|
||||
String pj = split1[1].split("/")[1];
|
||||
|
||||
|
||||
List<HierarchicalActionSet> actionSets = parseChangedSourceCodeWithGumTree2(prevFile, revFile, srcMLPath,isJava);
|
||||
|
||||
if (actionSets != null && actionSets.size() != 0) {
|
||||
|
||||
boolean processActionSet = true;
|
||||
|
||||
if (actionSets.size() > Integer.valueOf(hunkLimit)) {
|
||||
processActionSet = false;
|
||||
logger.debug("Skipping {} set size {}", diffentryFile.getName(), hunkLimit);
|
||||
}
|
||||
|
||||
int hunkSet = 0;
|
||||
if (processActionSet) {
|
||||
|
||||
for (HierarchicalActionSet actionSet : actionSets) {
|
||||
// FileOutputStream f = null;
|
||||
|
||||
try {
|
||||
|
||||
String astNodeType = actionSet.getAstNodeType();
|
||||
// if (astNodeType.equals(rootType)){
|
||||
//
|
||||
// }
|
||||
actionSet.toString();
|
||||
int size = actionSet.getActionSize();
|
||||
|
||||
|
||||
String key = astNodeType + "/" + String.valueOf(size) + "/" + pj + "_" + diffentryFile.getName() + "_" + String.valueOf(hunkSet);
|
||||
|
||||
ITree targetTree = EDiffHelper.getTargets(actionSet,isJava);
|
||||
ITree actionTree = EDiffHelper.getActionTrees(actionSet);
|
||||
ITree shapeTree = EDiffHelper.getShapeTree(actionSet,isJava);
|
||||
try (Jedis inner = innerPool.getResource()) {
|
||||
|
||||
inner.hset("dump", key, actionSet.toString());
|
||||
inner.hset(key, "actionTree", actionTree.toStaticHashString());
|
||||
inner.hset(key, "targetTree", targetTree.toStaticHashString());
|
||||
inner.hset(key, "shapeTree", shapeTree.toStaticHashString());
|
||||
}
|
||||
// File f = new File(root+"dumps/"+astNodeType+"/"+String.valueOf(size)+"/");
|
||||
// f.mkdirs();
|
||||
// f = new File(root+"dumps/"+key);
|
||||
//
|
||||
// FileUtils.writeByteArrayToFile(f,EDiffHelper.kryoSerialize(actionSet));
|
||||
// FileUtils.writeByteArrayToFile(f,EDiffHelper.commonsSerialize(actionSet));
|
||||
// FileUtils.writeByteArrayToFile(f,actionSet.toString().getBytes());
|
||||
// FileOutputStream fos = new FileOutputStream(f);
|
||||
// ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||
// oos.writeObject(EDiffHelper.kryoSerialize(actionSet));
|
||||
// oos.flush();
|
||||
// oos.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("error", e);
|
||||
// e.printStackTrace();
|
||||
}
|
||||
hunkSet++;
|
||||
}
|
||||
try (Jedis inner = innerPool.getResource()) {
|
||||
inner.hset("diffEntry", pj + "_" + diffentryFile.getName(), "1");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+26
-2
@@ -1,4 +1,4 @@
|
||||
package edu.lu.uni.serval.fixminer.akka.ediff;
|
||||
package edu.lu.uni.serval.fixminer.ediff;
|
||||
|
||||
import edu.lu.uni.serval.fixminer.akka.BaseMessage;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
@@ -10,6 +10,7 @@ public class EDiffMessage extends BaseMessage{
|
||||
|
||||
private List<MessageFile> msgFiles;
|
||||
|
||||
|
||||
public JedisPool getInnerPool() {
|
||||
return innerPool;
|
||||
}
|
||||
@@ -20,14 +21,28 @@ public class EDiffMessage extends BaseMessage{
|
||||
|
||||
private JedisPool innerPool;
|
||||
|
||||
public String getSrcMLPath() {
|
||||
return srcMLPath;
|
||||
}
|
||||
|
||||
private String srcMLPath;
|
||||
|
||||
public String getRootType() {
|
||||
return rootType;
|
||||
}
|
||||
|
||||
private String rootType;
|
||||
|
||||
|
||||
|
||||
|
||||
public EDiffMessage(int id, List<MessageFile> msgFiles,String eDiffTimeout,JedisPool pool) {
|
||||
|
||||
public EDiffMessage(int id, List<MessageFile> msgFiles,String eDiffTimeout,JedisPool pool,String srcMLPath,String rootType) {
|
||||
super(id,new Long(eDiffTimeout));
|
||||
this.msgFiles = msgFiles;
|
||||
this.innerPool = pool;
|
||||
this.srcMLPath = srcMLPath;
|
||||
this.rootType = rootType;
|
||||
}
|
||||
public EDiffMessage(int id, List<MessageFile> msgFiles,Long eDiffTimeout,JedisPool pool) {
|
||||
super(id,eDiffTimeout);
|
||||
@@ -36,6 +51,15 @@ public class EDiffMessage extends BaseMessage{
|
||||
}
|
||||
|
||||
|
||||
public EDiffMessage(int id, List<MessageFile> filesOfWorkers, long seconds_to_wait, JedisPool innerPool, String srcMLPath,String rootType) {
|
||||
|
||||
super(id,seconds_to_wait);
|
||||
this.msgFiles = filesOfWorkers;
|
||||
this.innerPool = innerPool;
|
||||
this.srcMLPath = srcMLPath;
|
||||
this.rootType = rootType;
|
||||
}
|
||||
|
||||
public List<MessageFile> getMsgFiles() {
|
||||
return msgFiles;
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package edu.lu.uni.serval.fixminer.ediff;
|
||||
|
||||
import com.github.gumtreediff.actions.model.Action;
|
||||
import com.github.gumtreediff.gen.srcml.GumTreeCComparer;
|
||||
import edu.lu.uni.serval.gumtree.GumTreeComparer;
|
||||
|
||||
|
||||
import edu.lu.uni.serval.utils.ListSorter;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Parse fix patterns with GumTree.
|
||||
*
|
||||
* @author kui.liu
|
||||
*
|
||||
*/
|
||||
public class EDiffParser extends Parser {
|
||||
|
||||
/*
|
||||
* ResultType:
|
||||
* 0: normal GumTree results.
|
||||
* 1: null GumTree result.
|
||||
* 2: No source code changes.
|
||||
* 3: No Statement Change.
|
||||
* 4: useless violations
|
||||
*/
|
||||
public int resultType = 0;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Regroup GumTree results without remove the modification of variable names.
|
||||
*
|
||||
* @param prevFile
|
||||
* @param revFile
|
||||
* @return
|
||||
*/
|
||||
protected List<HierarchicalActionSet> parseChangedSourceCodeWithGumTree2(File prevFile, File revFile,String srcMLPath,boolean isJava) {
|
||||
List<HierarchicalActionSet> actionSets = new ArrayList<>();
|
||||
// GumTree results
|
||||
// boolean isJava =false;
|
||||
List<Action> gumTreeResults = null;
|
||||
if (isJava){
|
||||
// if (revFile.getName().endsWith(".c") & prevFile.getName().endsWith(".c") || revFile.getName().endsWith(".h") & prevFile.getName().endsWith(".h")){
|
||||
// gumTreeResults = new GumTreeComparer().compareCFilesWithGumTree(prevFile, revFile);
|
||||
|
||||
gumTreeResults = new GumTreeComparer().compareTwoFilesWithGumTree(prevFile, revFile);
|
||||
|
||||
|
||||
}else{
|
||||
gumTreeResults = new GumTreeCComparer().compareCFilesWithGumTree(prevFile, revFile,srcMLPath);
|
||||
|
||||
}
|
||||
if (gumTreeResults == null) {
|
||||
this.resultType = 1;
|
||||
return null;
|
||||
} else if (gumTreeResults.size() == 0){
|
||||
this.resultType = 2;
|
||||
return actionSets;
|
||||
} else {
|
||||
// Regroup GumTre results.
|
||||
List<HierarchicalActionSet> allActionSets = null;
|
||||
if (isJava){
|
||||
allActionSets = new HierarchicalRegrouper().regroupGumTreeResults(gumTreeResults);
|
||||
}else{
|
||||
HashSet<Integer> removeType = new HashSet<Integer>(Arrays.asList(171,172,99,100,101,102));
|
||||
boolean b = gumTreeResults.stream().anyMatch(p -> removeType.contains(p.getNode().getType()));
|
||||
if(b){
|
||||
return actionSets;
|
||||
}
|
||||
allActionSets = new HierarchicalRegrouperForC().regroupGumTreeResults(gumTreeResults);
|
||||
}
|
||||
|
||||
|
||||
ListSorter<HierarchicalActionSet> sorter = new ListSorter<>(allActionSets);
|
||||
actionSets = sorter.sortAscending();
|
||||
|
||||
if (actionSets.size() == 0) {
|
||||
this.resultType = 3;
|
||||
}
|
||||
|
||||
return actionSets;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseFixPatterns(File prevFile, File revFile, File diffEntryFile, String project, JedisPool innerPool, String srcMLPath,String rootType,boolean isJava) {
|
||||
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void parseFixPatterns(File prevFile, File revFile, File diffEntryFile, String project, JedisPool innerPool) {
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
+7
-3
@@ -1,4 +1,4 @@
|
||||
package edu.lu.uni.serval.fixminer.akka.ediff;
|
||||
package edu.lu.uni.serval.fixminer.ediff;
|
||||
|
||||
import akka.actor.Props;
|
||||
import akka.actor.UntypedActor;
|
||||
@@ -43,6 +43,8 @@ public class EDiffWorker extends UntypedActor {
|
||||
int id = msg.getId();
|
||||
int counter = 0;
|
||||
JedisPool innerPool = msg.getInnerPool();
|
||||
String srcMLPath = msg.getSrcMLPath();
|
||||
String rootType = msg.getRootType();
|
||||
|
||||
for (MessageFile msgFile : files) {
|
||||
File revFile = msgFile.getRevFile();
|
||||
@@ -55,13 +57,15 @@ public class EDiffWorker extends UntypedActor {
|
||||
|
||||
final ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
// schedule the work
|
||||
final Future<?> future = executor.submit(new RunnableParser(prevFile, revFile, diffentryFile, parser,project,msg.getInnerPool()));
|
||||
|
||||
|
||||
final Future<?> future = executor.submit(new RunnableParser(prevFile, revFile, diffentryFile, parser,project,msg.getInnerPool(),srcMLPath,rootType,false));
|
||||
try {
|
||||
// wait for task to complete
|
||||
future.get(msg.getSECONDS_TO_WAIT(), TimeUnit.SECONDS);
|
||||
|
||||
counter ++;
|
||||
if (counter % 10 == 0) {
|
||||
if (counter % 1000 == 0) {
|
||||
log.info("Worker #" + id +" finalized parsing " + counter + " files... remaing "+ (files.size() - counter));
|
||||
}
|
||||
} catch (TimeoutException e) {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package edu.lu.uni.serval.fixminer.akka.ediff;
|
||||
package edu.lu.uni.serval.fixminer.ediff;
|
||||
|
||||
import com.github.gumtreediff.actions.model.Action;
|
||||
import com.github.gumtreediff.tree.ITree;
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
package edu.lu.uni.serval.fixminer.akka.ediff;
|
||||
package edu.lu.uni.serval.fixminer.ediff;
|
||||
|
||||
import com.github.gumtreediff.actions.model.*;
|
||||
import com.github.gumtreediff.tree.ITree;
|
||||
import edu.lu.uni.serval.utils.ASTNodeMap;
|
||||
import edu.lu.uni.serval.utils.ListSorter;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -0,0 +1,534 @@
|
||||
package edu.lu.uni.serval.fixminer.ediff;
|
||||
|
||||
|
||||
import com.github.gumtreediff.actions.model.Action;
|
||||
import com.github.gumtreediff.actions.model.*;
|
||||
import com.github.gumtreediff.gen.srcml.NodeMap_new;
|
||||
import com.github.gumtreediff.tree.ITree;
|
||||
import edu.lu.uni.serval.utils.ListSorter;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Regroup GumTree results to a hierarchical construction.
|
||||
*
|
||||
* @author kui.liu
|
||||
*
|
||||
*/
|
||||
public class HierarchicalRegrouperForC {
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// GumTreeComparer com = new GumTreeComparer();
|
||||
// File cFile1 = new File("/Users/anilkoyuncu/bugStudy/dataset/GumTreeInput/linux-stable/prevFiles/prev_0a3d00_b404bc_drivers#pci#iov.c");
|
||||
// File cFile2 = new File("/Users/anilkoyuncu/bugStudy/dataset/GumTreeInput/linux-stable/revFiles/0a3d00_b404bc_drivers#pci#iov.c");
|
||||
// List<Action> action = com.compareTwoFilesWithGumTreeForCCode(cFile1, cFile2);
|
||||
// List<HierarchicalActionSet> actionSet = new HierarchicalRegrouperForC().regroupGumTreeResults(action);
|
||||
// System.out.println(actionSet);
|
||||
// }
|
||||
|
||||
List<HierarchicalActionSet> actionSets = new ArrayList<>();
|
||||
|
||||
public List<HierarchicalActionSet> regroupGumTreeResults(List<Action> actions) {
|
||||
/*
|
||||
* First, sort actions by their positions.
|
||||
*/
|
||||
// List<Action> actions = new ListSorter<Action>(actionsArgu).sortAscending();
|
||||
// if (actions == null) {
|
||||
// actions = actionsArgu;
|
||||
// }
|
||||
|
||||
/*
|
||||
* Second, group actions by their positions.
|
||||
*/
|
||||
HierarchicalActionSet actionSet = null;
|
||||
for(Action act : actions){
|
||||
// if(act.getNode().getType() == 19 && act.getNode().getLabel().equals("")){
|
||||
// continue;
|
||||
// }
|
||||
Action parentAct = findParentAction(act, actions);
|
||||
|
||||
if (parentAct == null) {
|
||||
actionSet = createActionSet(act, parentAct, null);
|
||||
actionSets.add(actionSet);
|
||||
} else {
|
||||
if (!addToAactionSet(act, parentAct, actionSets)) {
|
||||
// The index of the parent action in the actions' list is larger than the index of this action.
|
||||
actionSet = createActionSet(act, parentAct, null);
|
||||
actionSets.add(actionSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Third, add the subActionSet to its parent ActionSet.
|
||||
*/
|
||||
List<HierarchicalActionSet> reActionSets = new ArrayList<>();
|
||||
for (HierarchicalActionSet actSet : actionSets) {
|
||||
Action parentAct = actSet.getParentAction();
|
||||
if (parentAct != null) {
|
||||
addToActionSets(actSet, parentAct, actionSets);
|
||||
} else {
|
||||
// TypeDeclaration, FieldDeclaration, MethodDeclaration, Statement.
|
||||
// CatchClause, ConstructorInvocation, SuperConstructorInvocation, SwitchCase
|
||||
// String astNodeType = actSet.getAstNodeType();
|
||||
// if (astNodeType.endsWith("TypeDeclaration") || astNodeType.endsWith("FieldDeclaration") || astNodeType.endsWith("EnumDeclaration") ||
|
||||
// astNodeType.endsWith("MethodDeclaration") || astNodeType.endsWith("Statement") ||
|
||||
// astNodeType.endsWith("ConstructorInvocation") || astNodeType.endsWith("CatchClause") || astNodeType.endsWith("SwitchCase")) {
|
||||
if (isStatement(actSet.getNode())) {
|
||||
reActionSets.add(actSet);
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
List<HierarchicalActionSet> reActionSets1 = new ArrayList<>();
|
||||
for(HierarchicalActionSet a:reActionSets){
|
||||
HierarchicalActionSet hierarchicalActionSet = purifyActionSet(a);
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = divideBlocks(hierarchicalActionSet);
|
||||
if(hierarchicalActionSets != null){
|
||||
reActionSets1.addAll(hierarchicalActionSets);
|
||||
}else{
|
||||
reActionSets1.add(hierarchicalActionSet);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return reActionSets1;
|
||||
// return reActionSets;
|
||||
}
|
||||
private HierarchicalActionSet purifyActionSet(HierarchicalActionSet actionSet){
|
||||
HierarchicalActionSet hierarchicalActionSet = removeBlocks(actionSet);
|
||||
// hierarchicalActionSet = removeIFthenBlocks(hierarchicalActionSet);
|
||||
// hierarchicalActionSet = removeParentForSingle(hierarchicalActionSet);
|
||||
// hierarchicalActionSet = removeParentNode(hierarchicalActionSet);
|
||||
return hierarchicalActionSet;
|
||||
// return actionSet;
|
||||
}
|
||||
|
||||
private List<HierarchicalActionSet> divideBlocks(HierarchicalActionSet actionSet){
|
||||
if (actionSet.getAstNodeType().equals("block") || actionSet.getAstNodeType().equals("function")){
|
||||
List<HierarchicalActionSet> subActions = actionSet.getSubActions();
|
||||
if (subActions.size() > 1) {
|
||||
boolean b = subActions.stream().allMatch(p -> NodeMap_new.getKeysByValue(NodeMap_new.StatementMap, p.getAstNodeType()).size() == 1 && p.getAstNodeType().equals(subActions.get(0).getAstNodeType()) && p.getAction().getName().equals(subActions.get(0).getAction().getName()));
|
||||
if (b ) {
|
||||
subActions.stream().forEach(p -> p.setParent(null));
|
||||
List<HierarchicalActionSet> collect = subActions.stream().map(p -> purifyActionSet(p)).collect(Collectors.toList());
|
||||
return collect;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<HierarchicalActionSet> postOrder(HierarchicalActionSet a) {
|
||||
List<HierarchicalActionSet> trees = new ArrayList<>();
|
||||
getAllSubActions(a, trees);
|
||||
return trees;
|
||||
}
|
||||
private void getAllSubActions(HierarchicalActionSet a,List<HierarchicalActionSet> as) {
|
||||
|
||||
List<HierarchicalActionSet> subActions = a.getSubActions();
|
||||
if (subActions.size() != 0){
|
||||
for (HierarchicalActionSet s : subActions) {
|
||||
getAllSubActions(s, as);
|
||||
}
|
||||
|
||||
}
|
||||
as.add(a);
|
||||
// List<HierarchicalActionSet> b = new ArrayList<HierarchicalActionSet>();
|
||||
// for (HierarchicalActionSet child: this.getSubActions())
|
||||
// b.add(child);
|
||||
// return b;
|
||||
}
|
||||
|
||||
|
||||
Predicate<HierarchicalActionSet> predicate = x->NodeMap_new.getKeysByValue(NodeMap_new.StatementMap,x.getAstNodeType()).size() == 1 ;
|
||||
Predicate<HierarchicalActionSet> predicate1 = x->!x.getAstNodeType().equals("block");
|
||||
Predicate<HierarchicalActionSet> predicate2 = x->!x.getAstNodeType().equals("then");
|
||||
// Predicate<HierarchicalActionSet> predicate3 = p->p.getAction().getName().equals(subActions.get(0).getAction().getName()));
|
||||
private HierarchicalActionSet removeBlocks(HierarchicalActionSet actionSet){
|
||||
List<HierarchicalActionSet> subActions = actionSet.getSubActions();
|
||||
|
||||
|
||||
|
||||
Action action = actionSet.getAction();
|
||||
if (subActions.size() == 1){
|
||||
HierarchicalActionSet subaction = subActions.get(0);
|
||||
// if(!postOrder(subaction).stream().anyMatch(predicate.and(predicate1.and(predicate2)))){
|
||||
// return actionSet;
|
||||
// }
|
||||
List<HierarchicalActionSet> collect = postOrder(subaction).stream().filter(predicate.and(predicate1.and(predicate2))).collect(Collectors.toList());
|
||||
if(collect.size() == 0){
|
||||
return actionSet;
|
||||
}
|
||||
boolean b = collect.stream().anyMatch(p -> p.getAction().getName().equals(subActions.get(0).getAction().getName()));
|
||||
if(!b){
|
||||
return actionSet;
|
||||
}
|
||||
Action action1 = subaction.getAction();
|
||||
//else,then,block
|
||||
if(action.getClass().equals(action1.getClass()) && action.getName().equals("UPD")) {
|
||||
|
||||
// List<Integer> keysByValue = NodeMap_new.getKeysByValue(NodeMap_new.StatementMap, subaction.getAstNodeType());
|
||||
// if (keysByValue != null && keysByValue.size() == 1) {
|
||||
|
||||
subaction.setParent(null);
|
||||
return removeBlocks(subaction);
|
||||
|
||||
// }
|
||||
// if(areRelatedActions(action,action1)) {
|
||||
// if (subaction.getAstNodeType().equals("block")) {//|| subaction.getAstNodeType().equals("then") || subaction.getAstNodeType().equals("else")){
|
||||
// List<HierarchicalActionSet> subSubActions = subaction.getSubActions();
|
||||
// if (subSubActions.size() == 1) {
|
||||
//
|
||||
// HierarchicalActionSet subsubsubAction = subSubActions.get(0);
|
||||
// List<Integer> keysByValue = NodeMap_new.getKeysByValue(NodeMap_new.StatementMap, subsubsubAction.getAstNodeType());
|
||||
// if (keysByValue != null && keysByValue.size() == 1) {
|
||||
//
|
||||
// subsubsubAction.setParent(null);
|
||||
// return removeBlocks(subsubsubAction);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
return actionSet;
|
||||
|
||||
}
|
||||
|
||||
private HierarchicalActionSet removeParentNode(HierarchicalActionSet actionSet){
|
||||
List<HierarchicalActionSet> subActions = actionSet.getSubActions();
|
||||
Action action = actionSet.getAction();
|
||||
if (subActions.size() == 1) {
|
||||
HierarchicalActionSet subaction = subActions.get(0);
|
||||
if(!postOrder(subaction).stream().anyMatch(predicate.and(predicate1.and(predicate2)))){
|
||||
return actionSet;
|
||||
}
|
||||
Action action1 = subaction.getAction();
|
||||
if (!action.getClass().equals(action1.getClass())) {
|
||||
List<Integer> keysByValue = NodeMap_new.getKeysByValue(NodeMap_new.StatementMap, subaction.getAstNodeType());
|
||||
if (keysByValue != null && keysByValue.size() == 1) {
|
||||
subaction.setParent(null);
|
||||
return removeParentNode(subaction);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return actionSet;
|
||||
}
|
||||
|
||||
private HierarchicalActionSet removeParentForSingle(HierarchicalActionSet actionSet){
|
||||
List<HierarchicalActionSet> subActions = actionSet.getSubActions();
|
||||
Action action = actionSet.getAction();
|
||||
if (subActions.size() == 1){
|
||||
HierarchicalActionSet subaction = subActions.get(0);
|
||||
if(!postOrder(subaction).stream().anyMatch(predicate.and(predicate1.and(predicate2)))){
|
||||
return actionSet;
|
||||
}
|
||||
//else,then,block
|
||||
Action action1 = subaction.getAction();
|
||||
//else,then,block
|
||||
if(action.getClass().equals(action1.getClass()) && action.getName().equals("UPD")) {
|
||||
|
||||
// if(areRelatedActions(action,action1)) {
|
||||
if(!(subaction.getAstNodeType().equals("condition") || subaction.getAstNodeType().equals("init"))){
|
||||
List<Integer> keysByValue = NodeMap_new.getKeysByValue(NodeMap_new.StatementMap, subaction.getAstNodeType());
|
||||
if(keysByValue != null && keysByValue.size() ==1){
|
||||
subaction.setParent(null);
|
||||
return removeParentForSingle(subaction);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return actionSet;
|
||||
|
||||
}
|
||||
private HierarchicalActionSet removeIFthenBlocks(HierarchicalActionSet actionSet){
|
||||
List<HierarchicalActionSet> subActions = actionSet.getSubActions();
|
||||
Action action = actionSet.getAction();
|
||||
if (subActions.size() == 1){
|
||||
HierarchicalActionSet subaction = subActions.get(0);
|
||||
//else,then,block
|
||||
Action action1 = subaction.getAction();
|
||||
//else,then,block
|
||||
if(action.getClass().equals(action1.getClass())) {
|
||||
// if(areRelatedActions(action,action1)) {
|
||||
if (subaction.getAstNodeType().equals("then") || subaction.getAstNodeType().equals("else")) {//|| subaction.getAstNodeType().equals("then") || subaction.getAstNodeType().equals("else")){
|
||||
List<HierarchicalActionSet> subSubActions = subaction.getSubActions();
|
||||
if (subSubActions.size() == 1) {
|
||||
|
||||
HierarchicalActionSet subsubsubAction = subSubActions.get(0);
|
||||
if(!postOrder(subsubsubAction).stream().anyMatch(predicate.and(predicate1.and(predicate2)))){
|
||||
return actionSet;
|
||||
}
|
||||
if (subsubsubAction.getAstNodeType().equals("block")) {
|
||||
List<HierarchicalActionSet> subActions1 = subsubsubAction.getSubActions();
|
||||
if (subActions1.size() == 1) {
|
||||
HierarchicalActionSet hierarchicalActionSet = subActions1.get(0);
|
||||
List<Integer> keysByValue = NodeMap_new.getKeysByValue(NodeMap_new.StatementMap, hierarchicalActionSet.getAstNodeType());
|
||||
if (keysByValue != null && keysByValue.size() == 1) {
|
||||
hierarchicalActionSet.setParent(null);
|
||||
return removeBlocks(hierarchicalActionSet);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return actionSet;
|
||||
|
||||
}
|
||||
|
||||
private HierarchicalActionSet createActionSet(Action act, Action parentAct, HierarchicalActionSet parent) {
|
||||
HierarchicalActionSet actionSet = new HierarchicalActionSet();
|
||||
actionSet.setAction(act);
|
||||
actionSet.setActionString(parseAction(act.toString()));
|
||||
actionSet.setParentAction(parentAct);
|
||||
actionSet.setNode(act.getNode());
|
||||
actionSet.setParent(parent);
|
||||
return actionSet;
|
||||
}
|
||||
|
||||
private String parseAction(String actStr1) {
|
||||
// UPD 25@@!a from !a to isTrue(a) at 69
|
||||
String[] actStrArrays = actStr1.split("@@");
|
||||
String actStr = "";
|
||||
int length = actStrArrays.length;
|
||||
for (int i =0; i < length - 1; i ++) {
|
||||
String actStrFrag = actStrArrays[i];
|
||||
int index = actStrFrag.lastIndexOf(" ") + 1;
|
||||
String nodeType = actStrFrag.substring(index);
|
||||
if (!"".equals(nodeType)) {
|
||||
if (Character.isDigit(nodeType.charAt(0)) || (nodeType.startsWith("-") && Character.isDigit(nodeType.charAt(1)))) {
|
||||
try {
|
||||
int typeInt = Integer.parseInt(nodeType);
|
||||
if (NodeMap_new.map.containsKey(typeInt)) {
|
||||
String type = NodeMap_new.map.get(Integer.parseInt(nodeType));
|
||||
nodeType = type;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
nodeType = actStrFrag.substring(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
actStrFrag = actStrFrag.substring(0, index) + nodeType + "@@";
|
||||
actStr += actStrFrag;
|
||||
}
|
||||
actStr += actStrArrays[length - 1];
|
||||
return actStr;
|
||||
}
|
||||
|
||||
private void addToActionSets(HierarchicalActionSet actionSet, Action parentAct, List<HierarchicalActionSet> actionSets) {
|
||||
Action act = actionSet.getAction();
|
||||
for (HierarchicalActionSet actSet : actionSets) {
|
||||
if (actSet.equals(actionSet)) continue;
|
||||
Action action = actSet.getAction();
|
||||
|
||||
if (!areRelatedActions(action, act)) continue;
|
||||
if (action.equals(parentAct)) { // actSet is the parent of actionSet.
|
||||
actionSet.setParent(actSet);
|
||||
actSet.getSubActions().add(actionSet);
|
||||
sortSubActions(actSet);
|
||||
break;
|
||||
} else {
|
||||
if (isPossibileSubAction(action, act)) {
|
||||
// SubAction range: startPosition2 <= startPosition && startPosition + length <= startPosition2 + length2
|
||||
addToActionSets(actionSet, parentAct, actSet.getSubActions());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isPossibileSubAction(Action parent, Action child) {
|
||||
// if ((parent instanceof Update && !(child instanceof Addition))
|
||||
// || (parent instanceof Delete && child instanceof Delete)
|
||||
// || (parent instanceof Insert && (child instanceof Insert))) {
|
||||
// int startPosition = child.getPosition();
|
||||
// int length = child.getLength();
|
||||
// int startPosition2 = parent.getPosition();
|
||||
// int length2 = parent.getLength();
|
||||
//
|
||||
// if (!(startPosition2 <= startPosition && startPosition + length <= startPosition2 + length2)) {
|
||||
// // when act is not the sub-set of action.
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sortSubActions(HierarchicalActionSet actionSet) {
|
||||
ListSorter<HierarchicalActionSet> sorter = new ListSorter<HierarchicalActionSet>(actionSet.getSubActions());
|
||||
List<HierarchicalActionSet> subActions = sorter.sortAscending();
|
||||
if (subActions != null) {
|
||||
actionSet.setSubActions(subActions);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean addToAactionSet(Action act, Action parentAct, List<HierarchicalActionSet> actionSets) {
|
||||
for(HierarchicalActionSet actionSet : actionSets) {
|
||||
Action action = actionSet.getAction();
|
||||
|
||||
if (!areRelatedActions(action, act)) continue;
|
||||
|
||||
if (action.equals(parentAct)) { // actionSet is the parent of actSet.
|
||||
HierarchicalActionSet actSet = createActionSet(act, actionSet.getAction(), actionSet);
|
||||
actionSet.getSubActions().add(actSet);
|
||||
sortSubActions(actionSet);
|
||||
return true;
|
||||
} else {
|
||||
if (isPossibileSubAction(action, act)) {
|
||||
// SubAction range: startPosition2 <= startPosition && startPosition + length <= startP + length2
|
||||
List<HierarchicalActionSet> subActionSets = actionSet.getSubActions();
|
||||
if (subActionSets.size() > 0) {
|
||||
boolean added = addToAactionSet(act, parentAct, subActionSets);
|
||||
if (added) {
|
||||
return true;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Action findParentAction(Action action, List<Action> actions) {
|
||||
|
||||
ITree parent = action.getNode().getParent();
|
||||
if (action instanceof Addition) {
|
||||
parent = ((Addition) action).getParent(); // parent in the fixed source code tree
|
||||
}
|
||||
|
||||
// if (parent.getType() == 55) {
|
||||
// int type = action.getNode().getType();
|
||||
// // Modifier, NormalAnnotation, MarkerAnnotation, SingleMemberAnnotation
|
||||
// if (type != 83 && type != 77 && type != 78 && type != 79
|
||||
// && type != 5 && type != 39 && type != 43 && type != 74 && type != 75
|
||||
// && type != 76 && type != 84 && type != 87 && type != 88 && type != 42) {
|
||||
// // ArrayType, PrimitiveType, SimpleType, ParameterizedType,
|
||||
// // QualifiedType, WildcardType, UnionType, IntersectionType, NameQualifiedType, SimpleName
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
for (Action act : actions) {
|
||||
if (act instanceof Move){
|
||||
if(act.getNode().equals(action.getNode())){
|
||||
return act;
|
||||
}
|
||||
}
|
||||
else if (act.getNode().equals(parent)) {
|
||||
if (areRelatedActions(act, action)) {
|
||||
return act;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// List<Action> newParentActions = new ArrayList<>();
|
||||
// //TODO
|
||||
// private Action findParentAction(Action action, List<Action> actions) {
|
||||
//
|
||||
// ITree parent = action.getNode().getParent();
|
||||
// if (parent == null) return null;
|
||||
// if (action instanceof Addition) {
|
||||
// parent = ((Addition) action).getParent(); // parent in the fixed source code tree
|
||||
// }
|
||||
//
|
||||
// for (Action act : actions) {
|
||||
// if (act.getNode().equals(parent)) {
|
||||
// if (areRelatedActions(act, action)) {
|
||||
// return act;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// for (Action act : newParentActions) {
|
||||
// if (act.getNode().equals(parent)) {
|
||||
// if (areRelatedActions(act, action)) {
|
||||
// return act;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// ITree tree = action.getNode();
|
||||
// Action parentAction = null;
|
||||
// if (!isStatement(tree)) {
|
||||
// parentAction = new Update(parent, action.getNode().getParent());
|
||||
// newParentActions.add(parentAction);
|
||||
//
|
||||
// Action higherParentAct = findParentAction(parentAction, actions);
|
||||
// HierarchicalActionSet actionSet = null;
|
||||
// if (higherParentAct == null) {
|
||||
// actionSet = createActionSet(parentAction, higherParentAct, null);
|
||||
// actionSets.add(actionSet);
|
||||
// } else {
|
||||
// if (!addToAactionSet(parentAction, higherParentAct, actionSets)) {
|
||||
// // The index of the parent action in the actions' list is larger than the index of this action.
|
||||
// actionSet = createActionSet(parentAction, higherParentAct, null);
|
||||
// actionSets.add(actionSet);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return parentAction;
|
||||
// }
|
||||
|
||||
private boolean isStatement(ITree tree) {
|
||||
|
||||
|
||||
int nodeType = tree.getType();
|
||||
// List<ITree> collect = tree.getChildren().stream().filter(m -> m.getType() == 6).collect(Collectors.toList());
|
||||
// if (collect.size() > 0){
|
||||
// return true;
|
||||
// }
|
||||
if (NodeMap_new.StatementMap.containsKey(nodeType)){
|
||||
return true;
|
||||
}
|
||||
// else{
|
||||
// if((nodeType ==6) && tree.getParent().getType() == 1){
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (nodeType == 11 || nodeType == 16 || nodeType == 18 || nodeType == 21
|
||||
// || nodeType == 22 || nodeType == 23 || nodeType == 24 || nodeType == 84
|
||||
// || 30 == nodeType || nodeType == 31 || nodeType == 32 || nodeType == 33
|
||||
// || nodeType == 34 || nodeType == 35 || nodeType == 36 || nodeType == 40
|
||||
// || nodeType == 41 || nodeType == 49 || nodeType == 73 || nodeType == 81 || nodeType == 80 || nodeType == 46 || nodeType == 60
|
||||
// ||nodeType == 62 || nodeType == 64 || nodeType == 45 || nodeType == 85 || nodeType == 86 || nodeType == 59 || nodeType == 27 || nodeType == 25
|
||||
// || nodeType == 26 || nodeType ==93 || nodeType == 37 || nodeType == 38 || nodeType == 39 || nodeType == 89) {// TODO
|
||||
// return true;
|
||||
// }
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean areRelatedActions(Action parent, Action child) {
|
||||
// if (parent instanceof Move && !(child instanceof Move)) {// If action is MOV, its children must be MOV.
|
||||
// return false;
|
||||
// }
|
||||
if (parent instanceof Delete && !(child instanceof Delete)) {// If action is DEL, its children must be DEL.
|
||||
return false;
|
||||
}
|
||||
if (parent instanceof Insert && !(child instanceof Addition)) {// If action is INS, its children must be MOV or INS.
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
package edu.lu.uni.serval.fixminer.ediff;
|
||||
|
||||
import com.github.gumtreediff.tree.ITree;
|
||||
import edu.lu.uni.serval.utils.ClusterToPattern;
|
||||
import edu.lu.uni.serval.utils.EDiffHelper;
|
||||
import edu.lu.uni.serval.utils.PoolBuilder;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.javatuples.Pair;
|
||||
import org.junit.Test;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
|
||||
public class HunkParserTest {
|
||||
|
||||
@Test
|
||||
public void testSimple() throws IOException {
|
||||
// String input = "/Users/anil.koyuncu/projects/test/fixminer-core/python/data/gumInputLinux/revFiles/7f52f3_3845d29_drivers#pci#host#pcie-altera.c";
|
||||
|
||||
// String root = "//Users/anilkoyuncu/projects/gumInputLinux/";
|
||||
String root = "/Users/anilkoyuncu/projects/fixminer/fixminer-core/python/data/gumInputLinux/";
|
||||
String filename ="";
|
||||
// filename ="freebsd_ceca9b8_b864ac4_sys#kern#sched_ule.c"; //too long
|
||||
// filename ="openbsd_e592ec_39c81a_sys#arch#i386#pci#pci_machdep.c"; //not parseable 56 "parameter_list" "" () ( (57 "parameter" "" () ( (22 "decl" "" () ())))
|
||||
// filename ="openbsd_cbb6d2_4cab495_sys#lib#libsa#printf.c";
|
||||
// filename ="freebsd_bb1ce4_10d4c2_sbin#gvinum#gvinum.c"; //too long
|
||||
// filename ="freebsd_253913_35ea52_sys#netinet#ip_carp.c"; //ok
|
||||
// filename ="FFmpeg_4c9d1c_3da860_libavutil#file_open.c"; //not sure ifdef
|
||||
// filename ="gstreamer_0af74c_e8bae0_libs#gst#net#gstptpclock.c"; //not sure ifder
|
||||
// filename ="freebsd_abdbcc6_030063_sys#netinet#ip_carp.c"; //ok
|
||||
// filename ="linux_80d348_5b394b_fs#overlayfs#inode.c"; //ok
|
||||
// filename ="openbsd_43b185_e7495b_usr.bin#cvs#rcs.c"; //okish
|
||||
// filename ="openbsd_e592ec_39c81a_sys#arch#i386#pci#pci_machdep.c"; //(56 "parameter_list" "" () ( (57 "parameter" "" () ( (22 "decl" "" () ())))
|
||||
// filename ="openbsd_cbb6d2_4cab495_sys#lib#libsa#printf.c"; //not parseable 56 "parameter_list" "" () ( (57 "parameter" "" () ( (22 "decl" "" () ())))
|
||||
// filename ="FFmpeg_9219ec_647696_libavfilter#trim.c"; //partial
|
||||
// filename ="vlc_92b7fd_f745f6_modules#control#dbus#dbus.c"; //okish
|
||||
// filename ="vlc_eeb662_966879_modules#video_chroma#copy.c"; //ok
|
||||
// filename ="omp_19fae3_1e4dcd_src#mca#mpool#sm#mpool_sm_mmap.c"; // cannot find
|
||||
// filename ="FFmpeg_a8343bf_2b2039_libavformat#riff.c"; // ok
|
||||
// filename ="freebsd_32766e4_200ff4_sbin#routed#parms.c"; // ok
|
||||
// filename ="openbsd_150ddd_cf0e20_usr.sbin#user#user.c"; //notok
|
||||
// filename ="openbsd_6fac1e_c3b383_usr.bin#tmux#window-copy.c"; //notok
|
||||
// filename ="freebsd_0cb6f2_b4c742_sys#dev#ipw#if_ipw.c"; //notok
|
||||
// filename ="php-src_7defd5_da06f7_ext#mbstring#mbstring.c"; //notok (19 "expr_stmt" "" () ()))))
|
||||
// filename ="libtiff_177169_71715f_tools#tiff2ps.c"; //notok (19 "expr_stmt" "" () ()))))
|
||||
filename ="linux_955c1dd_0aaee4_drivers#gpu#drm#i915#gvt#handlers.c"; //notok (19 "expr_stmt" "" () ()))))
|
||||
|
||||
// filename ="FFmpeg_0726b2_66d2ff_libav#jpeg.c";
|
||||
String pj = filename.split("_")[0];
|
||||
filename = filename.replace(pj+"_","");
|
||||
// root = root + pj + "/";
|
||||
root = root + "codeflaws/";
|
||||
|
||||
|
||||
filename ="287-A-14208510-14208532.c";
|
||||
// filename = "474-A-15925943-15925951.c"; //mot ok
|
||||
// filename = "6-C-11536006-11536039.c"; //okish
|
||||
// filename = "500-A-18298071-18298124.c"; //ok
|
||||
// filename = "106-B-4027414-4027447.c"; //ok
|
||||
// filename = "572-B-12669194-12669278.c"; //ok
|
||||
// filename = "514-A-16254510-16254521.c"; //ok
|
||||
// filename = "405-B-12287356-12287584.c"; //ok
|
||||
// filename = "630-R-17825199-17825235.c"; //notok
|
||||
File revFile = new File(root + "revFiles/"+ filename);
|
||||
File prevFile =new File(root + "prevFiles/prev_"+filename);
|
||||
// File diffFile =new File();
|
||||
String path = root + "DiffEntries/"+filename + ".txt";
|
||||
System.out.println(path);
|
||||
// String data = "";
|
||||
// data = new String(Files.readAllBytes(Paths.get(root + "DiffEntries/"+filename + ".txt")));
|
||||
|
||||
EDiffHunkParser parser = new EDiffHunkParser();
|
||||
|
||||
String srcMLPath = "/usr/local/bin/srcml";
|
||||
// String srcMLPath = "/Users/anil.koyuncu/Downloads/srcML.0.9.5/bin/srcml";
|
||||
parser.parseChangedSourceCodeWithGumTree2(prevFile, revFile, srcMLPath,false);
|
||||
// ITree t = new SrcmlCppTreeGenerator().generateFromFile(input).getRoot();
|
||||
// Assert.assertEquals(148, t.getSize());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void dumpFnction() throws Exception {
|
||||
String pattern = "function/20/gstreamer_0af74c_e8bae0_libs#gst#net#gstptpclock.c.txt_0";
|
||||
// String pattern = "function/20/FFmpeg_4c9d1c_3da860_libavutil#file_open.c.txt_0";
|
||||
ClusterToPattern.main("6399","/Users/anil.koyuncu/projects/fixminer/fixminer-core/python/data/redis","ALLdumps-gumInput.rdb ",pattern);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void newCTest(){
|
||||
String root = "/Users/anilkoyuncu/projects/gumInputLinux/linux/";
|
||||
String filename = "6a28fd_93ad867_drivers#tty#goldfish.c";
|
||||
|
||||
String srcMLPath = "/Users/anilkoyuncu/Downloads/srcML2/src2srcml";
|
||||
File revFile = new File(root + "revFiles/"+ filename);
|
||||
File prevFile =new File(root + "prevFiles/prev_"+filename);
|
||||
File diffFile = new File(root + "DiffEntries/"+filename+".txt");
|
||||
EDiffHunkParser parser = new EDiffHunkParser();
|
||||
parser.parseFixPatterns(prevFile,revFile,diffFile,"gumInputLinux",null,srcMLPath,null,false);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSimpleJava() throws IOException {
|
||||
|
||||
|
||||
String root = "/Users/anil.koyuncu/projects/test/fixminer-core/python/data/gumInput/spring-amqp/";
|
||||
|
||||
String filename = "5d6e02_e597c5_spring-rabbit#src#main#java#org#springframework#amqp#rabbit#connection#ConnectionFactoryUtils.java";
|
||||
File revFile = new File(root +"/revFiles/"+filename);
|
||||
// File oldFile = new File(root +"first.c");
|
||||
File prevFile = new File(root +"/prevFiles/prev_"+filename);
|
||||
|
||||
EDiffHunkParser parser = new EDiffHunkParser();
|
||||
|
||||
parser.parseChangedSourceCodeWithGumTree2(prevFile, revFile,"",true);
|
||||
// ITree t = new SrcmlCppTreeGenerator().generateFromFile(input).getRoot();
|
||||
// Assert.assertEquals(148, t.getSize());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void rich() throws IOException {
|
||||
Instant start = Instant.now();
|
||||
final JedisPool outerPool = new JedisPool(PoolBuilder.getPoolConfig(), "localhost",Integer.valueOf("6399"),20000000);
|
||||
|
||||
EDiffHunkParser parser = new EDiffHunkParser();
|
||||
String root = "/Users/anil.koyuncu/projects/fixminer/gumInputLinux/linux/";
|
||||
String filename = "43f8987_f596c8_drivers#acpi#nfit#core.c";
|
||||
File revFile = new File(root + "revFiles/"+ filename);
|
||||
File prevFile =new File(root + "prevFiles/prev_"+filename);
|
||||
File diffFile = new File(root + "DiffEntries/"+filename+".txt");
|
||||
String srcMLPath = "/Users/anil.koyuncu/Downloads/srcML/src2srcml";
|
||||
parser.parseFixPatterns(prevFile,revFile,diffFile,"gumInputLinux",outerPool,srcMLPath,"if",false);
|
||||
String key = "if/3/linux_bb67dd_0922c7_sound#soc#sof#intel#hda.c.txt_0";
|
||||
File file2load = new File("/Users/anil.koyuncu/projects/fixminer/dumps/"+ key);
|
||||
byte[] dump = FileUtils.readFileToByteArray(file2load);
|
||||
|
||||
// String line = FileHelper.readFile(file2load);
|
||||
// ITree parent = null;
|
||||
// ITree children = null;
|
||||
//// if(line.isEmpty())
|
||||
//// continue;
|
||||
// TreeContext tc = new TreeContext();
|
||||
// line = line.replace("\"", "");
|
||||
// String[] split1 = line.split("\n");
|
||||
// int length = split1.length;
|
||||
// List<String> strings = new LinkedList<String>(Arrays.asList(split1));
|
||||
// ITree treeFromString = null;
|
||||
// int prevLev = 0;
|
||||
// int childPosition = 0;
|
||||
// for (String l:strings) {
|
||||
// int level = 0;
|
||||
// Pattern pattern = Pattern.compile("---");
|
||||
// Matcher matcher = pattern.matcher(l);
|
||||
// while (matcher.find())
|
||||
// level++;
|
||||
//
|
||||
// l = l.replace("---","");
|
||||
// l = l.trim();
|
||||
//
|
||||
// String[] split2;
|
||||
// List<Integer> keysByValue;
|
||||
// split2 = l.split(" ");
|
||||
// keysByValue = NodeMap_new.getKeysByValue(NodeMap_new.map, split2[1]);
|
||||
//
|
||||
//
|
||||
//
|
||||
// if(level == 0){
|
||||
// parent = tc.createTree(keysByValue.get(0), split2[0], null);
|
||||
// tc.setRoot(parent);
|
||||
//
|
||||
// }else if (level > prevLev) {
|
||||
// if (children == null) {
|
||||
// children = tc.createTree(keysByValue.get(0), split2[0], null);
|
||||
// children.setParentAndUpdateChildren(parent);
|
||||
// } else {
|
||||
//
|
||||
// ITree tree = tc.createTree(keysByValue.get(0), split2[0], null);
|
||||
// tree.setParentAndUpdateChildren(children);
|
||||
// children = tree;
|
||||
// }
|
||||
// }else if (level == prevLev){
|
||||
// ITree innerParent = children.getParent();
|
||||
// children = tc.createTree(keysByValue.get(0), split2[0], null);
|
||||
// children.setParentAndUpdateChildren(innerParent);
|
||||
// }else {
|
||||
// ITree innerParent = children.getParent();
|
||||
// children = tc.createTree(keysByValue.get(0), split2[0], null);
|
||||
// children.setParentAndUpdateChildren(innerParent.getParent());
|
||||
// }
|
||||
// prevLev = level;
|
||||
// }
|
||||
// tc.validate();
|
||||
// parent.getLength();
|
||||
|
||||
// HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.kryoDeseerialize(dump);
|
||||
// HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.commonsDeserialize(dump);
|
||||
// actionSet.toString();
|
||||
|
||||
|
||||
// CODE HERE
|
||||
Instant finish = Instant.now();
|
||||
long timeElapsed = Duration.between(start, finish).toMillis();
|
||||
System.out.println(timeElapsed);
|
||||
|
||||
// try (Jedis outer = outerPool.getResource()) {
|
||||
// try {
|
||||
//
|
||||
//
|
||||
//
|
||||
// byte[] s = outer.hget("dump".getBytes(), key.getBytes());
|
||||
// HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.kryoDeseerialize(s);
|
||||
// actionSet.getActionSize();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@Test
|
||||
public void testCompare(){
|
||||
final JedisPool outerPool = new JedisPool(PoolBuilder.getPoolConfig(), "localhost",Integer.valueOf("6399"),20000000);
|
||||
|
||||
Pair<ITree, HierarchicalActionSet> oldPair = null;
|
||||
Pair<ITree, HierarchicalActionSet> newPair = null;
|
||||
String matchKey = null;
|
||||
ArrayList<String> samePairs = new ArrayList<>();
|
||||
|
||||
String keyName = "if-3";
|
||||
String i = "2";
|
||||
String j = "21";
|
||||
// HashMap<String, String> filenames = AkkaTreeParser.filenames(outerPool);
|
||||
|
||||
// oldPair = EDiffHelper.getActions(keyName, i, outerPool, filenames);
|
||||
// newPair = EDiffHelper.getActions(keyName, j, outerPool, filenames);
|
||||
ITree oldActionTree = oldPair.getValue0();
|
||||
ITree newActionTree = newPair.getValue0();
|
||||
HierarchicalActionSet oldProject = oldPair.getValue1();
|
||||
HierarchicalActionSet newProject = newPair.getValue1();
|
||||
|
||||
ITree oldShapeTree = EDiffHelper.getShapeTree(oldProject,false);
|
||||
ITree newShapeTree = EDiffHelper.getShapeTree(newProject,false);
|
||||
|
||||
ITree oldTargetTree = EDiffHelper.getTargets(oldProject,false);
|
||||
ITree newTargetTree = EDiffHelper.getTargets(newProject,false);
|
||||
String oldShape = oldShapeTree.toStaticHashString();
|
||||
String newShape = newShapeTree.toStaticHashString();
|
||||
|
||||
if(oldShape.equals(newShape)){
|
||||
if(oldActionTree.toStaticHashString().equals(newActionTree.toStaticHashString())){
|
||||
if(oldTargetTree.toStaticHashString().equals(newTargetTree.toStaticHashString())){
|
||||
samePairs.add(matchKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+10
-2
@@ -1,4 +1,4 @@
|
||||
package edu.lu.uni.serval.fixminer.akka.ediff;
|
||||
package edu.lu.uni.serval.fixminer.ediff;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -9,13 +9,21 @@ public class MessageFile {
|
||||
private File diffEntryFile;
|
||||
private File positionFile;
|
||||
|
||||
public MessageFile(File revFile, File prevFile, File diffEntryFile) {
|
||||
|
||||
|
||||
private String project;
|
||||
|
||||
public MessageFile(File revFile, File prevFile, File diffEntryFile,String project) {
|
||||
super();
|
||||
this.revFile = revFile;
|
||||
this.prevFile = prevFile;
|
||||
this.diffEntryFile = diffEntryFile;
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public String getProject() { return project;}
|
||||
|
||||
public void setProject(String project) { this.project = project;}
|
||||
public File getRevFile() {
|
||||
return revFile;
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package edu.lu.uni.serval.fixminer.akka.ediff;
|
||||
package edu.lu.uni.serval.fixminer.ediff;
|
||||
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
@@ -20,7 +20,7 @@ public abstract class Parser implements ParserInterface {
|
||||
protected String originalTree = ""; // Guide of generating patches.
|
||||
protected String actionSets = ""; // Guide of generating patches.
|
||||
|
||||
public abstract void parseFixPatterns(File prevFile, File revFile, File diffEntryFile, String project, JedisPool innerPool);
|
||||
public abstract void parseFixPatterns(File prevFile, File revFile, File diffEntryFile, String project, JedisPool innerPool, String srcMLPath,String rootType,boolean isJava);
|
||||
|
||||
|
||||
@Override
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package edu.lu.uni.serval.fixminer.akka.ediff;
|
||||
package edu.lu.uni.serval.fixminer.ediff;
|
||||
|
||||
public interface ParserInterface {
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package edu.lu.uni.serval.fixminer.ediff;
|
||||
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class RunnableParser implements Runnable {
|
||||
|
||||
private File prevFile;
|
||||
private File revFile;
|
||||
private File diffEntryFile;
|
||||
private Parser parser;
|
||||
private String project;
|
||||
private JedisPool pool;
|
||||
private String srcMLPath;
|
||||
private String rootType;
|
||||
boolean isJava;
|
||||
|
||||
public RunnableParser(File prevFile, File revFile, File diffEntryFile, Parser parser) {
|
||||
this.prevFile = prevFile;
|
||||
this.revFile = revFile;
|
||||
this.diffEntryFile = diffEntryFile;
|
||||
this.parser = parser;
|
||||
}
|
||||
|
||||
public RunnableParser(File prevFile, File revFile, File diffEntryFile, Parser parser, String project, JedisPool innerPool) {
|
||||
this.prevFile = prevFile;
|
||||
this.revFile = revFile;
|
||||
this.diffEntryFile = diffEntryFile;
|
||||
this.parser = parser;
|
||||
this.project = project;
|
||||
this.pool = innerPool;
|
||||
}
|
||||
|
||||
public RunnableParser(File prevFile, File revFile, File diffEntryFile, Parser parser, String project, JedisPool innerPool,String srcMLPath,String rootType,boolean isJava) {
|
||||
this.prevFile = prevFile;
|
||||
this.revFile = revFile;
|
||||
this.diffEntryFile = diffEntryFile;
|
||||
this.parser = parser;
|
||||
this.project = project;
|
||||
this.pool = innerPool;
|
||||
this.srcMLPath = srcMLPath;
|
||||
this.rootType = rootType;
|
||||
this.isJava = isJava;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
parser.parseFixPatterns(prevFile, revFile, diffEntryFile,project,pool,srcMLPath,rootType,isJava);
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,157 @@
|
||||
package edu.lu.uni.serval.fixminer.ediff;
|
||||
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
public class TestPredefinedCases {
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testIFCase1() throws IOException {
|
||||
Properties appProps = new Properties();
|
||||
appProps.load(new FileInputStream("src/main/resource/app.properties"));
|
||||
String srcMLPath = appProps.getProperty("srcMLPath","FORKJOIN");
|
||||
|
||||
File revFile = new File("src/main/resource/testFiles/if_example_1.c");
|
||||
File prevFile =new File("src/main/resource/testFiles/prev_if_example_1.c");
|
||||
|
||||
EDiffHunkParser parser = new EDiffHunkParser();
|
||||
|
||||
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = parser.parseChangedSourceCodeWithGumTree2(prevFile, revFile, srcMLPath,false);
|
||||
hierarchicalActionSets.size();
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD if@@if x >= 5 y += 4 @TO@ if x > 5 y += 4 @AT@ 2 @LENGTH@ 16\n" +
|
||||
"---UPD condition@@x >= 5 @TO@ x > 5 @AT@ 2 @LENGTH@ 9\n" +
|
||||
"------UPD expr@@x >= 5 @TO@ x > 5 @AT@ 3 @LENGTH@ 6\n" +
|
||||
"---------UPD operator@@>= @TO@ > @AT@ 5 @LENGTH@ 2\n");
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testForCase1() throws IOException {
|
||||
Properties appProps = new Properties();
|
||||
appProps.load(new FileInputStream("src/main/resource/app.properties"));
|
||||
String srcMLPath = appProps.getProperty("srcMLPath","FORKJOIN");
|
||||
|
||||
File revFile = new File("src/main/resource/testFiles/for_example_1.c");
|
||||
File prevFile =new File("src/main/resource/testFiles/prev_for_example_1.c");
|
||||
|
||||
|
||||
|
||||
EDiffHunkParser parser = new EDiffHunkParser();
|
||||
|
||||
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = parser.parseChangedSourceCodeWithGumTree2(prevFile, revFile, srcMLPath,false);
|
||||
hierarchicalActionSets.size();
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD for@@i = 0 i < max i ++ if line ] == ' ' if line ] == '\\t' tab ++ @TO@ i = 0 i < max i ++ if line ] == ' ' space ++ if line ] == '\\t' tab ++ @AT@ 4 @LENGTH@ 60\n" +
|
||||
"---UPD block@@if line ] == ' ' if line ] == '\\t' tab ++ @TO@ if line ] == ' ' space ++ if line ] == '\\t' tab ++ @AT@ 26 @LENGTH@ 98\n" +
|
||||
"------UPD if@@if line ] == ' ' @TO@ if line ] == ' ' space ++ @AT@ 33 @LENGTH@ 16\n" +
|
||||
"---------UPD then@@ @TO@ space ++ @AT@ 54 @LENGTH@ 0\n" +
|
||||
"------------UPD block@@ @TO@ space ++ @AT@ 54 @LENGTH@ 22\n" +
|
||||
"---------------INS expr_stmt@@space ++ @TO@ block@@ @AT@ 62 @LENGTH@ 8\n" +
|
||||
"------------------INS expr@@space ++ @TO@ expr_stmt@@space ++ @AT@ 62 @LENGTH@ 8\n" +
|
||||
"---------------------INS name@@space @TO@ expr@@space ++ @AT@ 62 @LENGTH@ 5\n" +
|
||||
"---------------------INS operator@@++ @TO@ expr@@space ++ @AT@ 67 @LENGTH@ 2\n" +
|
||||
"---------------DEL continue@@ @AT@ 62 @LENGTH@ 0\n");
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testWhileCase1() throws IOException {
|
||||
Properties appProps = new Properties();
|
||||
appProps.load(new FileInputStream("src/main/resource/app.properties"));
|
||||
String srcMLPath = appProps.getProperty("srcMLPath", "FORKJOIN");
|
||||
|
||||
File revFile = new File("src/main/resource/testFiles/while_example_1.c");
|
||||
File prevFile = new File("src/main/resource/testFiles/prev_while_example_1.c");
|
||||
|
||||
|
||||
EDiffHunkParser parser = new EDiffHunkParser();
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = parser.parseChangedSourceCodeWithGumTree2(prevFile, revFile, srcMLPath,false);
|
||||
hierarchicalActionSets.size();
|
||||
Assert.assertEquals(hierarchicalActionSets.size(), 1);
|
||||
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(), "UPD do@@y = f x x -- print x x > 0 @TO@ y = f x x -- x > 0 @AT@ 0 @LENGTH@ 62\n" +
|
||||
"---UPD block@@y = f x x -- print x @TO@ y = f x x -- @AT@ 3 @LENGTH@ 42\n" +
|
||||
"------DEL expr_stmt@@print x @AT@ 33 @LENGTH@ 7\n" +
|
||||
"---------DEL expr@@print x @AT@ 33 @LENGTH@ 7\n" +
|
||||
"------------DEL call@@print x @AT@ 33 @LENGTH@ 7\n" +
|
||||
"---------------DEL name@@print @AT@ 33 @LENGTH@ 5\n" +
|
||||
"---------------DEL argument_list@@x @AT@ 38 @LENGTH@ 4\n" +
|
||||
"------------------DEL argument@@x @AT@ 39 @LENGTH@ 1\n" +
|
||||
"---------------------DEL expr@@x @AT@ 39 @LENGTH@ 1\n" +
|
||||
"------------------------DEL name@@x @AT@ 39 @LENGTH@ 1\n");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testIFRetrun() throws IOException {
|
||||
Properties appProps = new Properties();
|
||||
appProps.load(new FileInputStream("src/main/resource/app.properties"));
|
||||
String srcMLPath = appProps.getProperty("srcMLPath","FORKJOIN");
|
||||
|
||||
File revFile = new File("src/main/resource/testFiles/if_return.c");
|
||||
File prevFile =new File("src/main/resource/testFiles/prev_if_return.c");
|
||||
|
||||
|
||||
|
||||
EDiffHunkParser parser = new EDiffHunkParser();
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = parser.parseChangedSourceCodeWithGumTree2(prevFile, revFile, srcMLPath,false);
|
||||
hierarchicalActionSets.size();
|
||||
// Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
}
|
||||
@Test
|
||||
public void testIfElse() throws IOException {
|
||||
Properties appProps = new Properties();
|
||||
appProps.load(new FileInputStream("src/main/resource/app.properties"));
|
||||
String srcMLPath = appProps.getProperty("srcMLPath","FORKJOIN");
|
||||
|
||||
File revFile = new File("src/main/resource/testFiles/if_else.c");
|
||||
File prevFile =new File("src/main/resource/testFiles/prev_if_else.c");
|
||||
|
||||
|
||||
|
||||
EDiffHunkParser parser = new EDiffHunkParser();
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = parser.parseChangedSourceCodeWithGumTree2(prevFile, revFile, srcMLPath,false);
|
||||
hierarchicalActionSets.size();
|
||||
// Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStruct() throws IOException {
|
||||
Properties appProps = new Properties();
|
||||
appProps.load(new FileInputStream("src/main/resource/app.properties"));
|
||||
String srcMLPath = appProps.getProperty("srcMLPath","FORKJOIN");
|
||||
|
||||
File revFile = new File("src/main/resource/testFiles/struct.c");
|
||||
File prevFile =new File("src/main/resource/testFiles/prev_struct.c");
|
||||
|
||||
|
||||
|
||||
EDiffHunkParser parser = new EDiffHunkParser();
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = parser.parseChangedSourceCodeWithGumTree2(prevFile, revFile, srcMLPath,false);
|
||||
hierarchicalActionSets.size();
|
||||
// Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,898 @@
|
||||
package edu.lu.uni.serval.fixminer.ediff;
|
||||
|
||||
import com.github.gumtreediff.tree.ITree;
|
||||
import edu.lu.uni.serval.utils.CallShell;
|
||||
import edu.lu.uni.serval.utils.EDiffHelper;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
public class TestRealCases {
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void test_287_A_14208510_14208532() throws IOException {
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("287-A-14208510-14208532.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD block@@if g ][i ][j == '.' d ++ else h ++ if g ][i ][j + 1 == '.' d ++ else h ++ if g ][i + 1 ][j == '.' d ++ else h ++ if g ][i + 1 ][j + 1 == '.' d ++ else h ++ if d == 3 || h == 3 printf \"YES\" return 0 @TO@ if g ][i ][j == '.' d ++ else h ++ if g ][i ][j + 1 == '.' d ++ else h ++ if g ][i + 1 ][j == '.' d ++ else h ++ if g ][i + 1 ][j + 1 == '.' d ++ else h ++ if d >= 3 || h >= 3 printf \"YES\" return 0 d = 0 h = 0 @AT@ 199 @LENGTH@ 197\n" +
|
||||
"---UPD if@@if d == 3 || h == 3 printf \"YES\" return 0 @TO@ if d >= 3 || h >= 3 printf \"YES\" return 0 @AT@ 449 @LENGTH@ 41\n" +
|
||||
"------UPD condition@@d == 3 || h == 3 @TO@ d >= 3 || h >= 3 @AT@ 449 @LENGTH@ 16\n" +
|
||||
"---------UPD expr@@d == 3 || h == 3 @TO@ d >= 3 || h >= 3 @AT@ 450 @LENGTH@ 16\n" +
|
||||
"------------UPD operator@@== @TO@ >= @AT@ 451 @LENGTH@ 2\n" +
|
||||
"------------UPD operator@@== @TO@ >= @AT@ 459 @LENGTH@ 2\n" +
|
||||
"---INS expr_stmt@@d = 0 @TO@ block@@if g ][i ][j == '.' d ++ else h ++ if g ][i ][j + 1 == '.' d ++ else h ++ if g ][i + 1 ][j == '.' d ++ else h ++ if g ][i + 1 ][j + 1 == '.' d ++ else h ++ if d == 3 || h == 3 printf \"YES\" return 0 @AT@ 548 @LENGTH@ 5\n" +
|
||||
"------INS expr@@d = 0 @TO@ expr_stmt@@d = 0 @AT@ 548 @LENGTH@ 5\n" +
|
||||
"---------INS name@@d @TO@ expr@@d = 0 @AT@ 548 @LENGTH@ 1\n" +
|
||||
"---------INS operator@@= @TO@ expr@@d = 0 @AT@ 549 @LENGTH@ 1\n" +
|
||||
"---------INS literal:number@@0 @TO@ expr@@d = 0 @AT@ 550 @LENGTH@ 1\n" +
|
||||
"---INS expr_stmt@@h = 0 @TO@ block@@if g ][i ][j == '.' d ++ else h ++ if g ][i ][j + 1 == '.' d ++ else h ++ if g ][i + 1 ][j == '.' d ++ else h ++ if g ][i + 1 ][j + 1 == '.' d ++ else h ++ if d == 3 || h == 3 printf \"YES\" return 0 @AT@ 553 @LENGTH@ 5\n" +
|
||||
"------INS expr@@h = 0 @TO@ expr_stmt@@h = 0 @AT@ 553 @LENGTH@ 5\n" +
|
||||
"---------INS name@@h @TO@ expr@@h = 0 @AT@ 553 @LENGTH@ 1\n" +
|
||||
"---------INS operator@@= @TO@ expr@@h = 0 @AT@ 554 @LENGTH@ 1\n" +
|
||||
"---------INS literal:number@@0 @TO@ expr@@h = 0 @AT@ 555 @LENGTH@ 1\n");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_287_A_14208521_14208532() throws IOException {
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("287-A-14208521-14208532.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),2);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"INS expr_stmt@@d = 0 @TO@ block@@if g ][i ][j == '.' d ++ else h ++ if g ][i ][j + 1 == '.' d ++ else h ++ if g ][i + 1 ][j == '.' d ++ else h ++ if g ][i + 1 ][j + 1 == '.' d ++ else h ++ if d >= 3 || h >= 3 printf \"YES\" return 0 @AT@ 548 @LENGTH@ 5\n" +
|
||||
"---INS expr@@d = 0 @TO@ expr_stmt@@d = 0 @AT@ 548 @LENGTH@ 5\n" +
|
||||
"------INS name@@d @TO@ expr@@d = 0 @AT@ 548 @LENGTH@ 1\n" +
|
||||
"------INS operator@@= @TO@ expr@@d = 0 @AT@ 549 @LENGTH@ 1\n" +
|
||||
"------INS literal:number@@0 @TO@ expr@@d = 0 @AT@ 550 @LENGTH@ 1\n");
|
||||
Assert.assertEquals(hierarchicalActionSets.get(1).toString(),"INS expr_stmt@@h = 0 @TO@ block@@if g ][i ][j == '.' d ++ else h ++ if g ][i ][j + 1 == '.' d ++ else h ++ if g ][i + 1 ][j == '.' d ++ else h ++ if g ][i + 1 ][j + 1 == '.' d ++ else h ++ if d >= 3 || h >= 3 printf \"YES\" return 0 @AT@ 553 @LENGTH@ 5\n" +
|
||||
"---INS expr@@h = 0 @TO@ expr_stmt@@h = 0 @AT@ 553 @LENGTH@ 5\n" +
|
||||
"------INS name@@h @TO@ expr@@h = 0 @AT@ 553 @LENGTH@ 1\n" +
|
||||
"------INS operator@@= @TO@ expr@@h = 0 @AT@ 554 @LENGTH@ 1\n" +
|
||||
"------INS literal:number@@0 @TO@ expr@@h = 0 @AT@ 555 @LENGTH@ 1\n");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_189_1682083_1682218() throws IOException {
|
||||
//TODO
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("189-B-1682083-1682218.c");
|
||||
// Assert.assertFalse(true);
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD expr_stmt@@k = MIN k h - j @TO@ t = MIN t h - j @AT@ 254 @LENGTH@ 15\n" +
|
||||
"---UPD expr@@k = MIN k h - j @TO@ t = MIN t h - j @AT@ 254 @LENGTH@ 15\n" +
|
||||
"------UPD name@@k @TO@ t @AT@ 254 @LENGTH@ 1\n" +
|
||||
"------UPD call@@MIN k h - j @TO@ MIN t h - j @AT@ 258 @LENGTH@ 11\n" +
|
||||
"---------UPD argument_list@@k h - j @TO@ t h - j @AT@ 261 @LENGTH@ 7\n" +
|
||||
"------------UPD argument@@k @TO@ t @AT@ 262 @LENGTH@ 1\n" +
|
||||
"---------------UPD expr@@k @TO@ t @AT@ 262 @LENGTH@ 1\n" +
|
||||
"------------------UPD name@@k @TO@ t @AT@ 262 @LENGTH@ 1\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test_177_A2_1594730_1595168() throws IOException {
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("177-A2-1594730-1595168.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD if@@if i == ( n - 1 ) / 2 && j == ( n - 1 ) / 2 mid = a @TO@ if i == ( n + 1 ) / 2 && j == ( n + 1 ) / 2 mid = a @AT@ 350 @LENGTH@ 51\n" +
|
||||
"---UPD condition@@i == ( n - 1 ) / 2 && j == ( n - 1 ) / 2 @TO@ i == ( n + 1 ) / 2 && j == ( n + 1 ) / 2 @AT@ 350 @LENGTH@ 40\n" +
|
||||
"------UPD expr@@i == ( n - 1 ) / 2 && j == ( n - 1 ) / 2 @TO@ i == ( n + 1 ) / 2 && j == ( n + 1 ) / 2 @AT@ 351 @LENGTH@ 40\n" +
|
||||
"---------UPD operator@@- @TO@ + @AT@ 356 @LENGTH@ 1\n" +
|
||||
"---------UPD operator@@- @TO@ + @AT@ 370 @LENGTH@ 1\n");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_680_A_18343132_18343191() throws IOException {
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("680-A-18343132-18343191.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),2);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD if@@if b ][a ][i == 3 max = 3 * a ][i break; @TO@ if b ][a ][i >= 3 max = 3 * a ][i break; @AT@ 176 @LENGTH@ 40\n" +
|
||||
"---UPD condition@@b ][a ][i == 3 @TO@ b ][a ][i >= 3 @AT@ 176 @LENGTH@ 14\n" +
|
||||
"------UPD expr@@b ][a ][i == 3 @TO@ b ][a ][i >= 3 @AT@ 177 @LENGTH@ 14\n" +
|
||||
"---------UPD operator@@== @TO@ >= @AT@ 184 @LENGTH@ 2\n");
|
||||
Assert.assertEquals(hierarchicalActionSets.get(1).toString(),"UPD if@@if temp > max max = temp break; @TO@ if temp > max max = temp @AT@ 270 @LENGTH@ 31\n" +
|
||||
"---UPD then@@max = temp break; @TO@ max = temp @AT@ 282 @LENGTH@ 17\n" +
|
||||
"------UPD block@@max = temp break; @TO@ max = temp @AT@ 282 @LENGTH@ 17\n" +
|
||||
"---------DEL break@@break; @AT@ 296 @LENGTH@ 6\n");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_245_D_3671804_3671831() throws IOException {
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("245-D-3671804-3671831.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"MOV expr_stmt@@ans |= a @TO@ block@@ @AT@ 194 @LENGTH@ 8\n");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_197_B_18221952_18221968() throws IOException {
|
||||
//TODO not sure
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("197-B-18221952-18221968.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"INS expr_stmt@@i -- @TO@ block@@a ][0 /= i b ][0 /= i @AT@ 831 @LENGTH@ 4\n" +
|
||||
"---INS expr@@i -- @TO@ expr_stmt@@i -- @AT@ 831 @LENGTH@ 4\n" +
|
||||
"------INS name@@i @TO@ expr@@i -- @AT@ 831 @LENGTH@ 1\n" +
|
||||
"------INS operator@@-- @TO@ expr@@i -- @AT@ 832 @LENGTH@ 2\n");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_474_A_15226851_15226912() throws IOException {
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("474-A-15226851-15226912.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD block@@str ][i = s ][j + 1 @TO@ j ++ str ][i = s ][j @AT@ 560 @LENGTH@ 19\n" +
|
||||
"---INS expr_stmt@@j ++ @TO@ block@@str ][i = s ][j + 1 @AT@ 582 @LENGTH@ 4\n" +
|
||||
"------INS expr@@j ++ @TO@ expr_stmt@@j ++ @AT@ 582 @LENGTH@ 4\n" +
|
||||
"---------INS name@@j @TO@ expr@@j ++ @AT@ 582 @LENGTH@ 1\n" +
|
||||
"---------INS operator@@++ @TO@ expr@@j ++ @AT@ 583 @LENGTH@ 2\n" +
|
||||
"---UPD expr_stmt@@str ][i = s ][j + 1 @TO@ str ][i = s ][j @AT@ 582 @LENGTH@ 19\n" +
|
||||
"------UPD expr@@str ][i = s ][j + 1 @TO@ str ][i = s ][j @AT@ 582 @LENGTH@ 19\n" +
|
||||
"---------UPD name@@s ][j + 1 @TO@ s ][j @AT@ 589 @LENGTH@ 9\n" +
|
||||
"------------UPD index@@][j + 1 @TO@ ][j @AT@ 591 @LENGTH@ 7\n" +
|
||||
"---------------UPD expr@@[j + 1 @TO@ [j @AT@ 591 @LENGTH@ 6\n" +
|
||||
"------------------DEL operator@@+ @AT@ 592 @LENGTH@ 1\n" +
|
||||
"------------------DEL literal:number@@1 @AT@ 593 @LENGTH@ 1\n");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_469_B_8248222_8248281() throws IOException {
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("469-B-8248222-8248281.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD if@@if temp1 < r && temp2 > l for k = temp1 k <= temp2 k ++ t ][k = 1 @TO@ if temp1 <= r && temp2 >= l for k = temp1 k <= temp2 k ++ t ][k = 1 @AT@ 432 @LENGTH@ 65\n" +
|
||||
"---UPD condition@@temp1 < r && temp2 > l @TO@ temp1 <= r && temp2 >= l @AT@ 432 @LENGTH@ 22\n" +
|
||||
"------UPD expr@@temp1 < r && temp2 > l @TO@ temp1 <= r && temp2 >= l @AT@ 433 @LENGTH@ 22\n" +
|
||||
"---------UPD operator@@< @TO@ <= @AT@ 438 @LENGTH@ 1\n" +
|
||||
"---------UPD operator@@> @TO@ >= @AT@ 447 @LENGTH@ 1\n");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_189_B_17295034_17295064() throws IOException {
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("189-B-17295034-17295064.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD for@@for b = 2 b <= w b += 2 count += ( w - a + 1 ) * ( h - b + 1 ) @TO@ for b = 2 b <= h b += 2 count += ( w - a + 1 ) * ( h - b + 1 ) @AT@ 183 @LENGTH@ 62\n" +
|
||||
"---UPD control@@b = 2 b <= w b += 2 @TO@ b = 2 b <= h b += 2 @AT@ 183 @LENGTH@ 19\n" +
|
||||
"------UPD condition@@b <= w @TO@ b <= h @AT@ 188 @LENGTH@ 6\n" +
|
||||
"---------UPD expr@@b <= w @TO@ b <= h @AT@ 188 @LENGTH@ 6\n" +
|
||||
"------------UPD name@@w @TO@ h @AT@ 191 @LENGTH@ 1\n");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_244_B_5291533_5291541() throws IOException {
|
||||
//TODO not sure
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("244-B-5291533-5291541.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"INS elseif@@elseif if a == 784262 printf \"4079\\n\" @TO@ if@@if a <= 101 printf \"%d\\n\" a elseif if a == 123 printf \"113\\n\" elseif if a == 1000 printf \"352\\n\" elseif if a == 1000000000 printf \"40744\\n\" elseif if a == 999999999 printf \"40743\\n\" elseif if a == 999999998 printf \"40742\\n\" elseif if a == 999999997 printf \"40741\\n\" elseif if a == 909090901 printf \"38532\\n\" elseif if a == 142498040 printf \"21671\\n\" elseif if a == 603356456 printf \"31623\\n\" elseif if a == 64214872 printf \"15759\\n\" elseif if a == 820040584 printf \"36407\\n\" elseif if a == 442198 printf \"3071\\n\" elseif if a == 642678 printf \"3615\\n\" elseif if a == 468390 printf \"3223\\n\" elseif if a == 326806 printf \"2759\\n\" elseif if a == 940 printf \"331\\n\" elseif if a == 356 printf \"175\\n\" elseif if a == 132 printf \"114\\n\" elseif if a == 102 printf \"101\\n\" @AT@ 877 @LENGTH@ 37\n" +
|
||||
"---INS if@@if a == 784262 printf \"4079\\n\" @TO@ elseif@@elseif if a == 784262 printf \"4079\\n\" @AT@ 877 @LENGTH@ 30\n" +
|
||||
"------INS condition@@a == 784262 @TO@ if@@if a == 784262 printf \"4079\\n\" @AT@ 877 @LENGTH@ 11\n" +
|
||||
"---------INS expr@@a == 784262 @TO@ condition@@a == 784262 @AT@ 878 @LENGTH@ 11\n" +
|
||||
"------------INS name@@a @TO@ expr@@a == 784262 @AT@ 878 @LENGTH@ 1\n" +
|
||||
"------------INS operator@@== @TO@ expr@@a == 784262 @AT@ 879 @LENGTH@ 2\n" +
|
||||
"------------INS literal:number@@784262 @TO@ expr@@a == 784262 @AT@ 881 @LENGTH@ 6\n" +
|
||||
"------INS then@@printf \"4079\\n\" @TO@ if@@if a == 784262 printf \"4079\\n\" @AT@ 901 @LENGTH@ 15\n" +
|
||||
"---------INS block@@printf \"4079\\n\" @TO@ then@@printf \"4079\\n\" @AT@ 901 @LENGTH@ 15\n" +
|
||||
"------------INS expr_stmt@@printf \"4079\\n\" @TO@ block@@printf \"4079\\n\" @AT@ 901 @LENGTH@ 15\n" +
|
||||
"---------------INS expr@@printf \"4079\\n\" @TO@ expr_stmt@@printf \"4079\\n\" @AT@ 901 @LENGTH@ 15\n" +
|
||||
"------------------INS call@@printf \"4079\\n\" @TO@ expr@@printf \"4079\\n\" @AT@ 901 @LENGTH@ 15\n" +
|
||||
"---------------------INS name@@printf @TO@ call@@printf \"4079\\n\" @AT@ 901 @LENGTH@ 6\n" +
|
||||
"---------------------INS argument_list@@\"4079\\n\" @TO@ call@@printf \"4079\\n\" @AT@ 907 @LENGTH@ 8\n" +
|
||||
"------------------------INS argument@@\"4079\\n\" @TO@ argument_list@@\"4079\\n\" @AT@ 908 @LENGTH@ 8\n" +
|
||||
"---------------------------INS expr@@\"4079\\n\" @TO@ argument@@\"4079\\n\" @AT@ 908 @LENGTH@ 8\n" +
|
||||
"------------------------------INS literal:string@@\"4079\\n\" @TO@ expr@@\"4079\\n\" @AT@ 908 @LENGTH@ 8\n");
|
||||
|
||||
}
|
||||
@Test
|
||||
public void test_166_C_1395587_1395933() throws IOException {
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("166-C-1395587-1395933.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD if@@if array ][( n + 1 ) / 2 == x printf \"0\\n\" elseif if last < ( n + 1 ) / 2 printf \"%d\\n\" n - 2 * last elseif if first > ( n + 1 ) / 2 printf \"%d\\n\" 2 * first - n - 1 @TO@ if array ][( n + 1 ) / 2 - 1 == x printf \"0\\n\" elseif if last < ( n + 1 ) / 2 printf \"%d\\n\" n - 2 * last elseif if first > ( n + 1 ) / 2 printf \"%d\\n\" 2 * first - n - 1 elseif if n == 1 printf \"0\\n\" @AT@ 771 @LENGTH@ 164\n" +
|
||||
"---UPD condition@@array ][( n + 1 ) / 2 == x @TO@ array ][( n + 1 ) / 2 - 1 == x @AT@ 771 @LENGTH@ 26\n" +
|
||||
"------UPD expr@@array ][( n + 1 ) / 2 == x @TO@ array ][( n + 1 ) / 2 - 1 == x @AT@ 772 @LENGTH@ 26\n" +
|
||||
"---------UPD name@@array ][( n + 1 ) / 2 @TO@ array ][( n + 1 ) / 2 - 1 @AT@ 772 @LENGTH@ 21\n" +
|
||||
"------------UPD index@@][( n + 1 ) / 2 @TO@ ][( n + 1 ) / 2 - 1 @AT@ 778 @LENGTH@ 15\n" +
|
||||
"---------------UPD expr@@[( n + 1 ) / 2 @TO@ [( n + 1 ) / 2 - 1 @AT@ 778 @LENGTH@ 14\n" +
|
||||
"------------------INS operator@@- @TO@ expr@@[( n + 1 ) / 2 @AT@ 785 @LENGTH@ 1\n" +
|
||||
"------------------INS literal:number@@1 @TO@ expr@@[( n + 1 ) / 2 @AT@ 786 @LENGTH@ 1\n" +
|
||||
"---INS elseif@@elseif if n == 1 printf \"0\\n\" @TO@ if@@if array ][( n + 1 ) / 2 == x printf \"0\\n\" elseif if last < ( n + 1 ) / 2 printf \"%d\\n\" n - 2 * last elseif if first > ( n + 1 ) / 2 printf \"%d\\n\" 2 * first - n - 1 @AT@ 925 @LENGTH@ 29\n" +
|
||||
"------INS if@@if n == 1 printf \"0\\n\" @TO@ elseif@@elseif if n == 1 printf \"0\\n\" @AT@ 925 @LENGTH@ 22\n" +
|
||||
"---------INS condition@@n == 1 @TO@ if@@if n == 1 printf \"0\\n\" @AT@ 925 @LENGTH@ 6\n" +
|
||||
"------------INS expr@@n == 1 @TO@ condition@@n == 1 @AT@ 926 @LENGTH@ 6\n" +
|
||||
"---------------INS name@@n @TO@ expr@@n == 1 @AT@ 926 @LENGTH@ 1\n" +
|
||||
"---------------INS operator@@== @TO@ expr@@n == 1 @AT@ 927 @LENGTH@ 2\n" +
|
||||
"---------------INS literal:number@@1 @TO@ expr@@n == 1 @AT@ 929 @LENGTH@ 1\n" +
|
||||
"---------INS then@@printf \"0\\n\" @TO@ if@@if n == 1 printf \"0\\n\" @AT@ 932 @LENGTH@ 12\n" +
|
||||
"------------INS block@@printf \"0\\n\" @TO@ then@@printf \"0\\n\" @AT@ 932 @LENGTH@ 12\n" +
|
||||
"---------------INS expr_stmt@@printf \"0\\n\" @TO@ block@@printf \"0\\n\" @AT@ 932 @LENGTH@ 12\n" +
|
||||
"------------------INS expr@@printf \"0\\n\" @TO@ expr_stmt@@printf \"0\\n\" @AT@ 932 @LENGTH@ 12\n" +
|
||||
"---------------------INS call@@printf \"0\\n\" @TO@ expr@@printf \"0\\n\" @AT@ 932 @LENGTH@ 12\n" +
|
||||
"------------------------INS name@@printf @TO@ call@@printf \"0\\n\" @AT@ 932 @LENGTH@ 6\n" +
|
||||
"------------------------INS argument_list@@\"0\\n\" @TO@ call@@printf \"0\\n\" @AT@ 938 @LENGTH@ 5\n" +
|
||||
"---------------------------INS argument@@\"0\\n\" @TO@ argument_list@@\"0\\n\" @AT@ 939 @LENGTH@ 5\n" +
|
||||
"------------------------------INS expr@@\"0\\n\" @TO@ argument@@\"0\\n\" @AT@ 939 @LENGTH@ 5\n" +
|
||||
"---------------------------------INS literal:string@@\"0\\n\" @TO@ expr@@\"0\\n\" @AT@ 939 @LENGTH@ 5\n");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_315_A_6149995_6150754() throws IOException {
|
||||
//TODO not sure
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("315-A-6149995-6150754.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"INS expr_stmt@@a ][j = 0 @TO@ block@@ans -- @AT@ 377 @LENGTH@ 9\n" +
|
||||
"---INS expr@@a ][j = 0 @TO@ expr_stmt@@a ][j = 0 @AT@ 377 @LENGTH@ 9\n" +
|
||||
"------INS name@@a ][j @TO@ expr@@a ][j = 0 @AT@ 377 @LENGTH@ 5\n" +
|
||||
"---------INS name@@a @TO@ name@@a ][j @AT@ 377 @LENGTH@ 1\n" +
|
||||
"---------INS index@@][j @TO@ name@@a ][j @AT@ 379 @LENGTH@ 3\n" +
|
||||
"------------INS expr@@[j @TO@ index@@][j @AT@ 379 @LENGTH@ 2\n" +
|
||||
"---------------INS name@@[j @TO@ expr@@[j @AT@ 379 @LENGTH@ 2\n" +
|
||||
"------INS operator@@= @TO@ expr@@a ][j = 0 @AT@ 381 @LENGTH@ 1\n" +
|
||||
"------INS literal:number@@0 @TO@ expr@@a ][j = 0 @AT@ 382 @LENGTH@ 1\n");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_158_A_18237828_18237840() throws IOException {
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("158-A-18237828-18237840.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD if@@if ara ][i >= ara ][k - 1 count ++ @TO@ if ara ][i >= ara ][k - 1 && ara ][i != 0 count ++ @AT@ 219 @LENGTH@ 34\n" +
|
||||
"---UPD condition@@ara ][i >= ara ][k - 1 @TO@ ara ][i >= ara ][k - 1 && ara ][i != 0 @AT@ 219 @LENGTH@ 22\n" +
|
||||
"------UPD expr@@ara ][i >= ara ][k - 1 @TO@ ara ][i >= ara ][k - 1 && ara ][i != 0 @AT@ 220 @LENGTH@ 22\n" +
|
||||
"---------INS operator@@&& @TO@ expr@@ara ][i >= ara ][k - 1 @AT@ 236 @LENGTH@ 2\n" +
|
||||
"---------INS name@@ara ][i @TO@ expr@@ara ][i >= ara ][k - 1 @AT@ 239 @LENGTH@ 7\n" +
|
||||
"------------INS name@@ara @TO@ name@@ara ][i @AT@ 239 @LENGTH@ 3\n" +
|
||||
"------------INS index@@][i @TO@ name@@ara ][i @AT@ 243 @LENGTH@ 3\n" +
|
||||
"---------------INS expr@@[i @TO@ index@@][i @AT@ 243 @LENGTH@ 2\n" +
|
||||
"------------------INS name@@[i @TO@ expr@@[i @AT@ 243 @LENGTH@ 2\n" +
|
||||
"---------INS operator@@!= @TO@ expr@@ara ][i >= ara ][k - 1 @AT@ 245 @LENGTH@ 2\n" +
|
||||
"---------INS literal:number@@0 @TO@ expr@@ara ][i >= ara ][k - 1 @AT@ 247 @LENGTH@ 1\n");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_405_B_9434593_9434605() throws IOException {
|
||||
//TODO not sure
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("405-B-9434593-9434605.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),
|
||||
"INS else@@else i1 = 0 @TO@ if@@if input ][0 == '.' count = 1 @AT@ 295 @LENGTH@ 11\n" +
|
||||
"---INS block@@i1 = 0 @TO@ else@@else i1 = 0 @AT@ 295 @LENGTH@ 6\n" +
|
||||
"------INS expr_stmt@@i1 = 0 @TO@ block@@i1 = 0 @AT@ 295 @LENGTH@ 6\n" +
|
||||
"---------INS expr@@i1 = 0 @TO@ expr_stmt@@i1 = 0 @AT@ 295 @LENGTH@ 6\n" +
|
||||
"------------INS name@@i1 @TO@ expr@@i1 = 0 @AT@ 295 @LENGTH@ 2\n" +
|
||||
"------------INS operator@@= @TO@ expr@@i1 = 0 @AT@ 297 @LENGTH@ 1\n" +
|
||||
"------------INS literal:number@@0 @TO@ expr@@i1 = 0 @AT@ 298 @LENGTH@ 1\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test_489_A_9343123_9343126() throws IOException {
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("489-A-9343123-9343126.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD if@@if ZA ][d < ZA ][c d = c @TO@ if ZA ][d > ZA ][c d = c @AT@ 252 @LENGTH@ 24\n" +
|
||||
"---UPD condition@@ZA ][d < ZA ][c @TO@ ZA ][d > ZA ][c @AT@ 252 @LENGTH@ 15\n" +
|
||||
"------UPD expr@@ZA ][d < ZA ][c @TO@ ZA ][d > ZA ][c @AT@ 253 @LENGTH@ 15\n" +
|
||||
"---------UPD operator@@< @TO@ > @AT@ 259 @LENGTH@ 1\n");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_143_A_17964626_17964657() throws IOException {
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("143-A-17964626-17964657.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD for@@for a = 1 a < ( r1 % 10 ) a ++ for i = 1 i <= 1000 i ++ ar ][i = 0 ar ][a = 1 if a >= c1 || a >= d1 continue; b = r1 - a if ar ][b == 1 continue; else ar ][b = 1 if b >= c2 || b >= d2 continue; c = c1 - a if ar ][c == 1 continue; else ar ][c = 1 if c >= r2 || c >= d2 continue; d = d1 - a if ar ][d == 1 continue; if d >= r2 || d >= c2 continue; if b + c != d2 continue; if b + d != c2 continue; if c + d != r2 continue; if a > 9 || b > 9 || c > 9 || d > 9 continue; flag = 1 break; @TO@ for a = 1 a < r1 a ++ for i = 1 i <= 1000 i ++ ar ][i = 0 ar ][a = 1 if a >= c1 || a >= d1 continue; b = r1 - a if ar ][b == 1 continue; else ar ][b = 1 if b >= c2 || b >= d2 continue; c = c1 - a if ar ][c == 1 continue; else ar ][c = 1 if c >= r2 || c >= d2 continue; d = d1 - a if ar ][d == 1 continue; if d >= r2 || d >= c2 continue; if b + c != d2 continue; if b + d != c2 continue; if c + d != r2 continue; if a > 9 || b > 9 || c > 9 || d > 9 continue; flag = 1 break; @AT@ 187 @LENGTH@ 482\n" +
|
||||
"---UPD control@@a = 1 a < ( r1 % 10 ) a ++ @TO@ a = 1 a < r1 a ++ @AT@ 187 @LENGTH@ 26\n" +
|
||||
"------UPD condition@@a < ( r1 % 10 ) @TO@ a < r1 @AT@ 193 @LENGTH@ 15\n" +
|
||||
"---------UPD expr@@a < ( r1 % 10 ) @TO@ a < r1 @AT@ 193 @LENGTH@ 15\n" +
|
||||
"------------DEL operator@@( @AT@ 195 @LENGTH@ 1\n" +
|
||||
"------------DEL operator@@% @AT@ 198 @LENGTH@ 1\n" +
|
||||
"------------DEL literal:number@@10 @AT@ 199 @LENGTH@ 2\n" +
|
||||
"------------DEL operator@@) @AT@ 201 @LENGTH@ 1\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test_612_A_15750192_15750273() throws IOException {
|
||||
//TODO
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("612-A-15750192-15750273.c");
|
||||
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD for@@for i = p i <= k i ++ printf \"%c\" a ][i @TO@ for i = p i < k i ++ printf \"%c\" a ][i @AT@ 262 @LENGTH@ 39\n" +
|
||||
"---UPD control@@i = p i <= k i ++ @TO@ i = p i < k i ++ @AT@ 262 @LENGTH@ 17\n" +
|
||||
"------UPD condition@@i <= k @TO@ i < k @AT@ 267 @LENGTH@ 6\n" +
|
||||
"---------UPD expr@@i <= k @TO@ i < k @AT@ 267 @LENGTH@ 6\n" +
|
||||
"------------UPD operator@@<= @TO@ < @AT@ 268 @LENGTH@ 2\n");
|
||||
|
||||
}
|
||||
@Test
|
||||
public void test_344_A_17290259_17290309() throws IOException {
|
||||
//TODO
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("344-A-17290259-17290309.c");
|
||||
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD for@@for i = 0 i < n i ++ if a ][i + 1 == a ][i d = d + 1 else f = f + 1 i = i + 2 @TO@ for i = 0 i < n - 1 i ++ if a ][i + 1 == a ][i d = d + 1 else f = f + 1 @AT@ 158 @LENGTH@ 77\n" +
|
||||
"---UPD control@@i = 0 i < n i ++ @TO@ i = 0 i < n - 1 i ++ @AT@ 158 @LENGTH@ 16\n" +
|
||||
"------UPD condition@@i < n @TO@ i < n - 1 @AT@ 163 @LENGTH@ 5\n" +
|
||||
"---------UPD expr@@i < n @TO@ i < n - 1 @AT@ 163 @LENGTH@ 5\n" +
|
||||
"------------INS operator@@- @TO@ expr@@i < n @AT@ 166 @LENGTH@ 1\n" +
|
||||
"------------INS literal:number@@1 @TO@ expr@@i < n @AT@ 167 @LENGTH@ 1\n" +
|
||||
"---UPD block@@if a ][i + 1 == a ][i d = d + 1 else f = f + 1 i = i + 2 @TO@ if a ][i + 1 == a ][i d = d + 1 else f = f + 1 @AT@ 173 @LENGTH@ 56\n" +
|
||||
"------UPD if@@if a ][i + 1 == a ][i d = d + 1 else f = f + 1 i = i + 2 @TO@ if a ][i + 1 == a ][i d = d + 1 else f = f + 1 @AT@ 179 @LENGTH@ 56\n" +
|
||||
"---------UPD else@@else f = f + 1 i = i + 2 @TO@ else f = f + 1 @AT@ 218 @LENGTH@ 24\n" +
|
||||
"------------UPD block@@f = f + 1 i = i + 2 @TO@ f = f + 1 @AT@ 218 @LENGTH@ 19\n" +
|
||||
"---------------DEL expr_stmt@@i = i + 2 @AT@ 233 @LENGTH@ 9\n" +
|
||||
"------------------DEL expr@@i = i + 2 @AT@ 233 @LENGTH@ 9\n" +
|
||||
"---------------------DEL name@@i @AT@ 233 @LENGTH@ 1\n" +
|
||||
"---------------------DEL operator@@= @AT@ 234 @LENGTH@ 1\n" +
|
||||
"---------------------DEL name@@i @AT@ 235 @LENGTH@ 1\n" +
|
||||
"---------------------DEL operator@@+ @AT@ 236 @LENGTH@ 1\n" +
|
||||
"---------------------DEL literal:number@@2 @AT@ 237 @LENGTH@ 1\n");
|
||||
|
||||
}
|
||||
@Test
|
||||
public void test_452_B_7271987_7272004() throws IOException {
|
||||
//TODO
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("452-B-7271987-7272004.c");
|
||||
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD block@@int i j n m x i_temp 1 scanf \"%d %d\" & n & m if n == 0 printf \"0 1\\n\" printf \"0 %d\\n\" m printf \"0 0\\n\" printf \"0 %d\\n\" ( m - 1 ) return 0 elseif if m == 0 printf \"1 0\\n\" printf \"%d 0\\n\" n printf \"0 0\\n\" printf \"%d 0\\n\" ( n - 1 ) return 0 elseif if ( m == n ) && ( n == 1 ) printf \"%d %d\\n\" n m printf \"0 0\\n\" printf \"%d 0\\n\" n printf \"0 %d\\n\" ( m ) return 0 elseif if m == n if m + m * 1.41f > ( 2 * sqrt double m * m + ( m - 1 ) * ( m - 1 ) ) printf \"%d %d\\n\" n m printf \"0 0\\n\" printf \"%d 0\\n\" n printf \"0 %d\\n\" n else printf \"%d %d\\n\" n - 1 m printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"1 0\\n\" return 0 elseif if n < m if m + sqrt ( double ) n * n + m * m < ( 2 * sqrt double n - 1 * ( n - 1 ) + ( m ) * ( m ) ) printf \"%d %d\\n\" n - 1 m printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"1 0\\n\" return 0 else printf \"%d %d\\n0 0 \\n0 %d\\n%d 0\\n\" n m m n return 0 elseif if n > m if n + sqrt ( double ) n * n + m * m < ( 2 * sqrt ( double ) n * n + ( m - 1 ) * ( m - 1 ) ) printf \"%d %d\\n\" n m - 1 printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"0 1\\n\" return 0 else printf \"%d %d\\n0 0 \\n%d \\n0 %d\\n\" n m n m return 0 @TO@ int i j n m x i_temp 1 scanf \"%d %d\" & n & m if n == 0 printf \"0 1\\n\" printf \"0 %d\\n\" m printf \"0 0\\n\" printf \"0 %d\\n\" ( m - 1 ) return 0 elseif if m == 0 printf \"1 0\\n\" printf \"%d 0\\n\" n printf \"0 0\\n\" printf \"%d 0\\n\" ( n - 1 ) return 0 elseif if ( m == n ) && ( n == 1 ) printf \"%d %d\\n\" n m printf \"0 0\\n\" printf \"%d 0\\n\" n printf \"0 %d\\n\" ( m ) return 0 elseif if m == n if m + m * 1.41f > ( 2 * sqrt double m * m + ( m - 1 ) * ( m - 1 ) ) printf \"%d %d\\n\" n m printf \"0 0\\n\" printf \"%d 0\\n\" n printf \"0 %d\\n\" n else printf \"%d %d\\n\" n - 1 m printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"1 0\\n\" return 0 elseif if n < m if m + sqrt ( double ) n * n + m * m < ( 2 * sqrt double n - 1 * ( n - 1 ) + ( m ) * ( m ) ) printf \"%d %d\\n\" n - 1 m printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"1 0\\n\" return 0 else printf \"%d %d\\n0 0 \\n0 %d\\n%d 0\\n\" n m m n return 0 elseif if n > m if n + sqrt ( double ) n * n + m * m < ( 2 * sqrt ( double ) n * n + ( m - 1 ) * ( m - 1 ) ) printf \"%d %d\\n\" n m - 1 printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"0 1\\n\" return 0 else printf \"%d %d\\n0 0 \\n%d 0\\n0 %d\\n\" n m n m return 0 return 0 @AT@ 115 @LENGTH@ 1106\n" +
|
||||
"---UPD if@@if n == 0 printf \"0 1\\n\" printf \"0 %d\\n\" m printf \"0 0\\n\" printf \"0 %d\\n\" ( m - 1 ) return 0 elseif if m == 0 printf \"1 0\\n\" printf \"%d 0\\n\" n printf \"0 0\\n\" printf \"%d 0\\n\" ( n - 1 ) return 0 elseif if ( m == n ) && ( n == 1 ) printf \"%d %d\\n\" n m printf \"0 0\\n\" printf \"%d 0\\n\" n printf \"0 %d\\n\" ( m ) return 0 elseif if m == n if m + m * 1.41f > ( 2 * sqrt double m * m + ( m - 1 ) * ( m - 1 ) ) printf \"%d %d\\n\" n m printf \"0 0\\n\" printf \"%d 0\\n\" n printf \"0 %d\\n\" n else printf \"%d %d\\n\" n - 1 m printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"1 0\\n\" return 0 elseif if n < m if m + sqrt ( double ) n * n + m * m < ( 2 * sqrt double n - 1 * ( n - 1 ) + ( m ) * ( m ) ) printf \"%d %d\\n\" n - 1 m printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"1 0\\n\" return 0 else printf \"%d %d\\n0 0 \\n0 %d\\n%d 0\\n\" n m m n return 0 elseif if n > m if n + sqrt ( double ) n * n + m * m < ( 2 * sqrt ( double ) n * n + ( m - 1 ) * ( m - 1 ) ) printf \"%d %d\\n\" n m - 1 printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"0 1\\n\" return 0 else printf \"%d %d\\n0 0 \\n%d \\n0 %d\\n\" n m n m return 0 @TO@ if n == 0 printf \"0 1\\n\" printf \"0 %d\\n\" m printf \"0 0\\n\" printf \"0 %d\\n\" ( m - 1 ) return 0 elseif if m == 0 printf \"1 0\\n\" printf \"%d 0\\n\" n printf \"0 0\\n\" printf \"%d 0\\n\" ( n - 1 ) return 0 elseif if ( m == n ) && ( n == 1 ) printf \"%d %d\\n\" n m printf \"0 0\\n\" printf \"%d 0\\n\" n printf \"0 %d\\n\" ( m ) return 0 elseif if m == n if m + m * 1.41f > ( 2 * sqrt double m * m + ( m - 1 ) * ( m - 1 ) ) printf \"%d %d\\n\" n m printf \"0 0\\n\" printf \"%d 0\\n\" n printf \"0 %d\\n\" n else printf \"%d %d\\n\" n - 1 m printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"1 0\\n\" return 0 elseif if n < m if m + sqrt ( double ) n * n + m * m < ( 2 * sqrt double n - 1 * ( n - 1 ) + ( m ) * ( m ) ) printf \"%d %d\\n\" n - 1 m printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"1 0\\n\" return 0 else printf \"%d %d\\n0 0 \\n0 %d\\n%d 0\\n\" n m m n return 0 elseif if n > m if n + sqrt ( double ) n * n + m * m < ( 2 * sqrt ( double ) n * n + ( m - 1 ) * ( m - 1 ) ) printf \"%d %d\\n\" n m - 1 printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"0 1\\n\" return 0 else printf \"%d %d\\n0 0 \\n%d 0\\n0 %d\\n\" n m n m return 0 @AT@ 168 @LENGTH@ 1061\n" +
|
||||
"------UPD elseif@@elseif if n > m if n + sqrt ( double ) n * n + m * m < ( 2 * sqrt ( double ) n * n + ( m - 1 ) * ( m - 1 ) ) printf \"%d %d\\n\" n m - 1 printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"0 1\\n\" return 0 else printf \"%d %d\\n0 0 \\n%d \\n0 %d\\n\" n m n m return 0 @TO@ elseif if n > m if n + sqrt ( double ) n * n + m * m < ( 2 * sqrt ( double ) n * n + ( m - 1 ) * ( m - 1 ) ) printf \"%d %d\\n\" n m - 1 printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"0 1\\n\" return 0 else printf \"%d %d\\n0 0 \\n%d 0\\n0 %d\\n\" n m n m return 0 @AT@ 1116 @LENGTH@ 249\n" +
|
||||
"---------UPD if@@if n > m if n + sqrt ( double ) n * n + m * m < ( 2 * sqrt ( double ) n * n + ( m - 1 ) * ( m - 1 ) ) printf \"%d %d\\n\" n m - 1 printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"0 1\\n\" return 0 else printf \"%d %d\\n0 0 \\n%d \\n0 %d\\n\" n m n m return 0 @TO@ if n > m if n + sqrt ( double ) n * n + m * m < ( 2 * sqrt ( double ) n * n + ( m - 1 ) * ( m - 1 ) ) printf \"%d %d\\n\" n m - 1 printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"0 1\\n\" return 0 else printf \"%d %d\\n0 0 \\n%d 0\\n0 %d\\n\" n m n m return 0 @AT@ 1116 @LENGTH@ 242\n" +
|
||||
"------------UPD then@@if n + sqrt ( double ) n * n + m * m < ( 2 * sqrt ( double ) n * n + ( m - 1 ) * ( m - 1 ) ) printf \"%d %d\\n\" n m - 1 printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"0 1\\n\" return 0 else printf \"%d %d\\n0 0 \\n%d \\n0 %d\\n\" n m n m return 0 @TO@ if n + sqrt ( double ) n * n + m * m < ( 2 * sqrt ( double ) n * n + ( m - 1 ) * ( m - 1 ) ) printf \"%d %d\\n\" n m - 1 printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"0 1\\n\" return 0 else printf \"%d %d\\n0 0 \\n%d 0\\n0 %d\\n\" n m n m return 0 @AT@ 1123 @LENGTH@ 233\n" +
|
||||
"---------------UPD block@@if n + sqrt ( double ) n * n + m * m < ( 2 * sqrt ( double ) n * n + ( m - 1 ) * ( m - 1 ) ) printf \"%d %d\\n\" n m - 1 printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"0 1\\n\" return 0 else printf \"%d %d\\n0 0 \\n%d \\n0 %d\\n\" n m n m return 0 @TO@ if n + sqrt ( double ) n * n + m * m < ( 2 * sqrt ( double ) n * n + ( m - 1 ) * ( m - 1 ) ) printf \"%d %d\\n\" n m - 1 printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"0 1\\n\" return 0 else printf \"%d %d\\n0 0 \\n%d 0\\n0 %d\\n\" n m n m return 0 @AT@ 1123 @LENGTH@ 233\n" +
|
||||
"------------------UPD if@@if n + sqrt ( double ) n * n + m * m < ( 2 * sqrt ( double ) n * n + ( m - 1 ) * ( m - 1 ) ) printf \"%d %d\\n\" n m - 1 printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"0 1\\n\" return 0 else printf \"%d %d\\n0 0 \\n%d \\n0 %d\\n\" n m n m return 0 @TO@ if n + sqrt ( double ) n * n + m * m < ( 2 * sqrt ( double ) n * n + ( m - 1 ) * ( m - 1 ) ) printf \"%d %d\\n\" n m - 1 printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"0 1\\n\" return 0 else printf \"%d %d\\n0 0 \\n%d 0\\n0 %d\\n\" n m n m return 0 @AT@ 1129 @LENGTH@ 233\n" +
|
||||
"---------------------UPD else@@else printf \"%d %d\\n0 0 \\n%d \\n0 %d\\n\" n m n m return 0 @TO@ else printf \"%d %d\\n0 0 \\n%d 0\\n0 %d\\n\" n m n m return 0 @AT@ 1313 @LENGTH@ 55\n" +
|
||||
"------------------------UPD block@@printf \"%d %d\\n0 0 \\n%d \\n0 %d\\n\" n m n m return 0 @TO@ printf \"%d %d\\n0 0 \\n%d 0\\n0 %d\\n\" n m n m return 0 @AT@ 1313 @LENGTH@ 50\n" +
|
||||
"---------------------------UPD expr_stmt@@printf \"%d %d\\n0 0 \\n%d \\n0 %d\\n\" n m n m @TO@ printf \"%d %d\\n0 0 \\n%d 0\\n0 %d\\n\" n m n m @AT@ 1318 @LENGTH@ 41\n" +
|
||||
"------------------------------UPD expr@@printf \"%d %d\\n0 0 \\n%d \\n0 %d\\n\" n m n m @TO@ printf \"%d %d\\n0 0 \\n%d 0\\n0 %d\\n\" n m n m @AT@ 1318 @LENGTH@ 41\n" +
|
||||
"---------------------------------UPD call@@printf \"%d %d\\n0 0 \\n%d \\n0 %d\\n\" n m n m @TO@ printf \"%d %d\\n0 0 \\n%d 0\\n0 %d\\n\" n m n m @AT@ 1318 @LENGTH@ 41\n" +
|
||||
"------------------------------------UPD argument_list@@\"%d %d\\n0 0 \\n%d \\n0 %d\\n\" n m n m @TO@ \"%d %d\\n0 0 \\n%d 0\\n0 %d\\n\" n m n m @AT@ 1324 @LENGTH@ 34\n" +
|
||||
"---------------------------------------UPD argument@@\"%d %d\\n0 0 \\n%d \\n0 %d\\n\" @TO@ \"%d %d\\n0 0 \\n%d 0\\n0 %d\\n\" @AT@ 1325 @LENGTH@ 26\n" +
|
||||
"------------------------------------------UPD expr@@\"%d %d\\n0 0 \\n%d \\n0 %d\\n\" @TO@ \"%d %d\\n0 0 \\n%d 0\\n0 %d\\n\" @AT@ 1325 @LENGTH@ 26\n" +
|
||||
"---------------------------------------------UPD literal:string@@\"%d %d\\n0 0 \\n%d \\n0 %d\\n\" @TO@ \"%d %d\\n0 0 \\n%d 0\\n0 %d\\n\" @AT@ 1325 @LENGTH@ 26\n" +
|
||||
"---INS return@@return 0 @TO@ block@@int i j n m x i_temp 1 scanf \"%d %d\" & n & m if n == 0 printf \"0 1\\n\" printf \"0 %d\\n\" m printf \"0 0\\n\" printf \"0 %d\\n\" ( m - 1 ) return 0 elseif if m == 0 printf \"1 0\\n\" printf \"%d 0\\n\" n printf \"0 0\\n\" printf \"%d 0\\n\" ( n - 1 ) return 0 elseif if ( m == n ) && ( n == 1 ) printf \"%d %d\\n\" n m printf \"0 0\\n\" printf \"%d 0\\n\" n printf \"0 %d\\n\" ( m ) return 0 elseif if m == n if m + m * 1.41f > ( 2 * sqrt double m * m + ( m - 1 ) * ( m - 1 ) ) printf \"%d %d\\n\" n m printf \"0 0\\n\" printf \"%d 0\\n\" n printf \"0 %d\\n\" n else printf \"%d %d\\n\" n - 1 m printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"1 0\\n\" return 0 elseif if n < m if m + sqrt ( double ) n * n + m * m < ( 2 * sqrt double n - 1 * ( n - 1 ) + ( m ) * ( m ) ) printf \"%d %d\\n\" n - 1 m printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"1 0\\n\" return 0 else printf \"%d %d\\n0 0 \\n0 %d\\n%d 0\\n\" n m m n return 0 elseif if n > m if n + sqrt ( double ) n * n + m * m < ( 2 * sqrt ( double ) n * n + ( m - 1 ) * ( m - 1 ) ) printf \"%d %d\\n\" n m - 1 printf \"0 0\\n\" printf \"%d %d\\n\" n m printf \"0 1\\n\" return 0 else printf \"%d %d\\n0 0 \\n%d \\n0 %d\\n\" n m n m return 0 @AT@ 1385 @LENGTH@ 8\n" +
|
||||
"------INS expr@@0 @TO@ return@@return 0 @AT@ 1392 @LENGTH@ 1\n" +
|
||||
"---------INS literal:number@@0 @TO@ expr@@0 @AT@ 1392 @LENGTH@ 1\n");
|
||||
|
||||
|
||||
}
|
||||
@Test
|
||||
public void test_158_E_1314159_1314160() throws IOException {
|
||||
//TODO
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("158-E-1314159-1314160.c");
|
||||
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD expr_stmt@@ans = max ans 86401 - dp ][k @TO@ ans = max ans 86400 - dp ][k @AT@ 377 @LENGTH@ 28\n" +
|
||||
"---UPD expr@@ans = max ans 86401 - dp ][k @TO@ ans = max ans 86400 - dp ][k @AT@ 377 @LENGTH@ 28\n" +
|
||||
"------UPD call@@max ans 86401 - dp ][k @TO@ max ans 86400 - dp ][k @AT@ 383 @LENGTH@ 22\n" +
|
||||
"---------UPD argument_list@@ans 86401 - dp ][k @TO@ ans 86400 - dp ][k @AT@ 386 @LENGTH@ 18\n" +
|
||||
"------------UPD argument@@86401 - dp ][k @TO@ 86400 - dp ][k @AT@ 393 @LENGTH@ 14\n" +
|
||||
"---------------UPD expr@@86401 - dp ][k @TO@ 86400 - dp ][k @AT@ 393 @LENGTH@ 14\n" +
|
||||
"------------------UPD literal:number@@86401 @TO@ 86400 @AT@ 393 @LENGTH@ 5\n");
|
||||
|
||||
}
|
||||
@Test
|
||||
public void test_250_A_2762401_2762408() throws IOException {
|
||||
//TODO
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("250-A-2762401-2762408.c");
|
||||
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD expr_stmt@@folders = ceil negative / 2 @TO@ folders = ceil negative / 2.0 @AT@ 289 @LENGTH@ 27\n" +
|
||||
"---UPD expr@@folders = ceil negative / 2 @TO@ folders = ceil negative / 2.0 @AT@ 289 @LENGTH@ 27\n" +
|
||||
"------UPD call@@ceil negative / 2 @TO@ ceil negative / 2.0 @AT@ 299 @LENGTH@ 17\n" +
|
||||
"---------UPD argument_list@@negative / 2 @TO@ negative / 2.0 @AT@ 303 @LENGTH@ 12\n" +
|
||||
"------------UPD argument@@negative / 2 @TO@ negative / 2.0 @AT@ 304 @LENGTH@ 12\n" +
|
||||
"---------------UPD expr@@negative / 2 @TO@ negative / 2.0 @AT@ 304 @LENGTH@ 12\n" +
|
||||
"------------------UPD literal:number@@2 @TO@ 2.0 @AT@ 313 @LENGTH@ 1\n");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_31_B_6435804_6435825() throws IOException {
|
||||
//TODO
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("31-B-6435804-6435825.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD for@@for i = 1 i <= strlen s i ++ if n == - 1 if s ][i != '@' n = i else printf \"No solution\\n\" return ( 0 ) if fl == 1 if s ][i != '@' fl = 0 if flag != 0 jj ++ cc ][jj = ',' for j = n j <= i j ++ jj ++ cc ][jj = s ][j else for j = n j <= i j ++ jj ++ cc ][jj = s ][j flag = 1 n = - 1 kon = i exit = 1 else printf \"No solution\\n\" return ( 0 ) elseif if s ][i == '@' fl = 1 @TO@ for i = 1 i < strlen s i ++ if n == - 1 if s ][i != '@' n = i else printf \"No solution\\n\" return ( 0 ) if fl == 1 if s ][i != '@' fl = 0 if flag != 0 jj ++ cc ][jj = ',' for j = n j <= i j ++ jj ++ cc ][jj = s ][j else for j = n j <= i j ++ jj ++ cc ][jj = s ][j flag = 1 n = - 1 kon = i exit = 1 else printf \"No solution\\n\" return ( 0 ) elseif if s ][i == '@' fl = 1 @AT@ 225 @LENGTH@ 368\n" +
|
||||
"---UPD control@@i = 1 i <= strlen s i ++ @TO@ i = 1 i < strlen s i ++ @AT@ 225 @LENGTH@ 24\n" +
|
||||
"------UPD condition@@i <= strlen s @TO@ i < strlen s @AT@ 233 @LENGTH@ 13\n" +
|
||||
"---------UPD expr@@i <= strlen s @TO@ i < strlen s @AT@ 233 @LENGTH@ 13\n" +
|
||||
"------------UPD operator@@<= @TO@ < @AT@ 235 @LENGTH@ 2\n");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_644_A_18166947_18166954() throws IOException {
|
||||
//TODO
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("644-A-18166947-18166954.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD for@@for i = 0 i < b i ++ for j = 0 j < b j ++ printf \"%lld \" array ][i ][j printf \"\\n\" @TO@ for i = 0 i < a i ++ for j = 0 j < b j ++ printf \"%lld \" array ][i ][j printf \"\\n\" @AT@ 1251 @LENGTH@ 82\n" +
|
||||
"---UPD control@@i = 0 i < b i ++ @TO@ i = 0 i < a i ++ @AT@ 1251 @LENGTH@ 16\n" +
|
||||
"------UPD condition@@i < b @TO@ i < a @AT@ 1256 @LENGTH@ 5\n" +
|
||||
"---------UPD expr@@i < b @TO@ i < a @AT@ 1256 @LENGTH@ 5\n" +
|
||||
"------------UPD name@@b @TO@ a @AT@ 1258 @LENGTH@ 1\n");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_5_B_10350073_10350082() throws IOException {
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("5-B-10350073-10350082.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD if@@if ! ( ( ml - l ) % 2 ) if right sl += 1 right = 1 - right @TO@ if ( ml - l ) % 2 if right sl += 1 right = 1 - right @AT@ 515 @LENGTH@ 58\n" +
|
||||
"---UPD condition@@! ( ( ml - l ) % 2 ) @TO@ ( ml - l ) % 2 @AT@ 515 @LENGTH@ 20\n" +
|
||||
"------UPD expr@@! ( ( ml - l ) % 2 ) @TO@ ( ml - l ) % 2 @AT@ 516 @LENGTH@ 20\n" +
|
||||
"---------DEL operator@@! @AT@ 516 @LENGTH@ 1\n" +
|
||||
"---------DEL operator@@( @AT@ 518 @LENGTH@ 1\n" +
|
||||
"---------DEL operator@@) @AT@ 530 @LENGTH@ 1\n");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_675_A_18211752_18211767() throws IOException {
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("675-A-18211752-18211767.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"MOV return@@return 0 @TO@ block@@if a == b printf \"YES\" else printf \"NO\" @AT@ 242 @LENGTH@ 8\n");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_158_A_18278572_18278586() throws IOException {
|
||||
//TODO
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("158-A-18278572-18278586.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD while@@while a ][i >= a ][k && i <= n count ++ i ++ @TO@ while a ][i >= a ][k && i <= n && a ][i != 0 count ++ i ++ @AT@ 501 @LENGTH@ 44\n" +
|
||||
"---UPD condition@@a ][i >= a ][k && i <= n @TO@ a ][i >= a ][k && i <= n && a ][i != 0 @AT@ 501 @LENGTH@ 24\n" +
|
||||
"------UPD expr@@a ][i >= a ][k && i <= n @TO@ a ][i >= a ][k && i <= n && a ][i != 0 @AT@ 502 @LENGTH@ 24\n" +
|
||||
"---------INS operator@@&& @TO@ expr@@a ][i >= a ][k && i <= n @AT@ 518 @LENGTH@ 2\n" +
|
||||
"---------INS name@@a ][i @TO@ expr@@a ][i >= a ][k && i <= n @AT@ 520 @LENGTH@ 5\n" +
|
||||
"------------INS name@@a @TO@ name@@a ][i @AT@ 520 @LENGTH@ 1\n" +
|
||||
"------------INS index@@][i @TO@ name@@a ][i @AT@ 522 @LENGTH@ 3\n" +
|
||||
"---------------INS expr@@[i @TO@ index@@][i @AT@ 522 @LENGTH@ 2\n" +
|
||||
"------------------INS name@@[i @TO@ expr@@[i @AT@ 522 @LENGTH@ 2\n" +
|
||||
"---------INS operator@@!= @TO@ expr@@a ][i >= a ][k && i <= n @AT@ 524 @LENGTH@ 2\n" +
|
||||
"---------INS literal:number@@0 @TO@ expr@@a ][i >= a ][k && i <= n @AT@ 526 @LENGTH@ 1\n");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_31_B_136044_136045() throws IOException {
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("31-B-136044-136045.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"MOV if@@if flag puts ans + 1 else printf \"No solution\\n\" @TO@ block@@long i long l long flag 0 long tot 0 gets str + 1 l = strlen str + 1 if str ][1 == '@' || str ][l == '@' end for i = 1 i <= l - 2 i ++ if str ][i == '@' && ( str ][i + 1 == '@' || str ][i + 2 == '@' ) end for i = 1 i <= l i ++ if flag && str ][i + 1 == '@' ans ][++ tot = ',' if str ][i == '@' flag = 1 ans ][++ tot = str ][i if flag puts ans + 1 else printf \"No solution\\n\" end return 0 @AT@ 937 @LENGTH@ 48\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_432_A_16886797_16886828() throws IOException {
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("432-A-16886797-16886828.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"MOV if@@if z <= 5 - y s ++ @TO@ block@@scanf \"%d\" & z @AT@ 132 @LENGTH@ 18\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_507_A_16886367_16886377() throws IOException {
|
||||
//TODO macro
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("507-A-16886367-16886377.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD block@@int x 0 n 0 s 0 i j k h ][105 0 a ][105 0 c ][105 0 y 0 top 0 scanf \"%d %d\" & n & k FOR i 0 n scanf \"%d\" & c ][i FOR i 0 n a ][i = i + 1 FOR i 0 n FOR j 1 n if c ][j - 1 > c ][j s = c ][j c ][j = c ][j - 1 c ][j - 1 = s s = a ][j a ][j = a ][j - 1 a ][j - 1 = s FOR i 0 n top += c ][i if top > k break; printf \"%d\\n\" i FOR j 0 n printf \"%d \" a ][j return 0 @TO@ int x 0 n 0 s 0 i j k h ][105 0 a ][105 0 c ][105 0 y 0 top 0 scanf \"%d %d\" & n & k FOR i 0 n scanf \"%d\" & c ][i FOR i 0 n a ][i = i + 1 FOR i 0 n FOR j 1 n if c ][j - 1 > c ][j s = c ][j c ][j = c ][j - 1 c ][j - 1 = s s = a ][j a ][j = a ][j - 1 a ][j - 1 = s FOR i 0 n top += c ][i if top > k break; printf \"%d\\n\" i FOR j 0 i printf \"%d \" a ][j return 0 @AT@ 270 @LENGTH@ 356\n" +
|
||||
"---UPD macro@@FOR j 0 n @TO@ FOR j 0 i @AT@ 701 @LENGTH@ 9\n" +
|
||||
"------UPD argument_list@@j 0 n @TO@ j 0 i @AT@ 704 @LENGTH@ 5\n" +
|
||||
"---------UPD argument@@n @TO@ i @AT@ 709 @LENGTH@ 1\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_25_D_110126_110132() throws IOException {
|
||||
//TODO macro
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("25-D-110126-110132.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD block@@int i j k l m n int a ][1200 b ][1200 unused ][1200 int ind ][1200 int cnt ][1200 int res_a ][1200 res_b ][1200 res_c ][1200 res_d ][1200 int shima int res bef scanf \"%d\" & n m = n - 1 rep i m scanf \"%d%d\" a + i b + i , a ][i -- , b ][i -- unionInit ind n rep i m unionConnect ind a ][i b ][i shima = 0 rep i m cnt ][unionGet ind i = 1 rep i n shima += cnt ][i res = 0 bef = - 1 rep i n if cnt ][i if bef >= 0 res_c ][res = bef res_d ][res ++ = i bef = i res = 0 rep k m unused ][k = 0 rep k m unionInit ind n rep i m if unused ][i == 0 if i != k unionConnect ind a ][i b ][i rep i n cnt ][i = 0 rep i n cnt ][unionGet ind i = 1 j = 0 rep i n j += cnt ][i if j == shima unused ][k = 1 res_a ][res = a ][k res_b ][res ++ = b ][k printf \"%d\\n\" res rep i res printf \"%d %d %d %d\\n\" res_a ][i + 1 res_b ][i + 1 res_c ][i + 1 res_d ][i + 1 return 0 @TO@ int i j k l m n int a ][1200 b ][1200 unused ][1200 int ind ][1200 int cnt ][1200 int res_a ][1200 res_b ][1200 res_c ][1200 res_d ][1200 int shima int res bef scanf \"%d\" & n m = n - 1 rep i m scanf \"%d%d\" a + i b + i , a ][i -- , b ][i -- unionInit ind n rep i m unionConnect ind a ][i b ][i shima = 0 rep i n cnt ][unionGet ind i = 1 rep i n shima += cnt ][i res = 0 bef = - 1 rep i n if cnt ][i if bef >= 0 res_c ][res = bef res_d ][res ++ = i bef = i res = 0 rep k m unused ][k = 0 rep k m unionInit ind n rep i m if unused ][i == 0 if i != k unionConnect ind a ][i b ][i rep i n cnt ][i = 0 rep i n cnt ][unionGet ind i = 1 j = 0 rep i n j += cnt ][i if j == shima unused ][k = 1 res_a ][res = a ][k res_b ][res ++ = b ][k printf \"%d\\n\" res rep i res printf \"%d %d %d %d\\n\" res_a ][i + 1 res_b ][i + 1 res_c ][i + 1 res_d ][i + 1 return 0 @AT@ 411 @LENGTH@ 843\n" +
|
||||
"---UPD macro@@rep i m @TO@ rep i n @AT@ 746 @LENGTH@ 7\n" +
|
||||
"------UPD argument_list@@i m @TO@ i n @AT@ 749 @LENGTH@ 3\n" +
|
||||
"---------UPD argument@@m @TO@ n @AT@ 752 @LENGTH@ 1\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_490_A_14580360_14580456() throws IOException {
|
||||
//TODO
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("490-A-14580360-14580456.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(),1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD block@@int n i j k l scanf \"%d\" & n int a ][5005 b ][5005 c ][5005 d ][5005 int w 0 x 0 y 0 for i = 1 , j = 1 , k = 1 , l = 1 i <= n i ++ scanf \"%d\" & a ][i if a ][i == 1 b ][j = i w ++ j ++ elseif if a ][i == 2 c ][k = i x ++ k ++ elseif if a ][i == 3 d ][l = i y ++ l ++ int min w if x < min min = x elseif if y < min min = y printf \"%d\\n\" min for i = 1 i <= min i ++ printf \"%d %d %d\\n\" b ][i c ][i d ][i return 0 @TO@ int n i j k l scanf \"%d\" & n int a ][5005 b ][5005 c ][5005 d ][5005 int w 0 x 0 y 0 for i = 1 , j = 1 , k = 1 , l = 1 i <= n i ++ scanf \"%d\" & a ][i if a ][i == 1 b ][j = i w ++ j ++ elseif if a ][i == 2 c ][k = i x ++ k ++ elseif if a ][i == 3 d ][l = i y ++ l ++ int min w if x < min min = x if y < min min = y printf \"%d\\n\" min for i = 1 i <= min i ++ printf \"%d %d %d\\n\" b ][i c ][i d ][i return 0 @AT@ 51 @LENGTH@ 409\n" +
|
||||
"---UPD if@@if x < min min = x elseif if y < min min = y @TO@ if x < min min = x @AT@ 507 @LENGTH@ 44\n" +
|
||||
"------DEL elseif@@elseif if y < min min = y @AT@ 548 @LENGTH@ 25\n" +
|
||||
"---MOV if@@if y < min min = y @TO@ block@@int n i j k l scanf \"%d\" & n int a ][5005 b ][5005 c ][5005 d ][5005 int w 0 x 0 y 0 for i = 1 , j = 1 , k = 1 , l = 1 i <= n i ++ scanf \"%d\" & a ][i if a ][i == 1 b ][j = i w ++ j ++ elseif if a ][i == 2 c ][k = i x ++ k ++ elseif if a ][i == 3 d ][l = i y ++ l ++ int min w if x < min min = x elseif if y < min min = y printf \"%d\\n\" min for i = 1 i <= min i ++ printf \"%d %d %d\\n\" b ][i c ][i d ][i return 0 @AT@ 548 @LENGTH@ 18\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_336_A_11394760_11394769() throws IOException {
|
||||
//TODO
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("336-A-11394760-11394769.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(), 1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(), "UPD block@@ll x y ll zero 0 scanf \"%lld%lld\" & x & y if x >= 0 && y >= 0 printf \"%lld %lld %lld %lld\\n\" zero x + y x + y zero if x < 0 && y >= 0 printf \"%lld %lld %lld %lld\\n\" - ( - x + y ) zero zero - x + y elseif if x >= 0 && y < 0 printf \"%lld %lld %lld %lld\\n\" zero - ( x - y ) x - y zero else printf \"%lld %lld %lld %lld\\n\" - ( - x - y ) zero zero - ( - x - y ) return 0 @TO@ ll x y ll zero 0 scanf \"%lld%lld\" & x & y if x >= 0 && y >= 0 printf \"%lld %lld %lld %lld\\n\" zero x + y x + y zero elseif if x < 0 && y >= 0 printf \"%lld %lld %lld %lld\\n\" - ( - x + y ) zero zero - x + y elseif if x >= 0 && y < 0 printf \"%lld %lld %lld %lld\\n\" zero - ( x - y ) x - y zero else printf \"%lld %lld %lld %lld\\n\" - ( - x - y ) zero zero - ( - x - y ) return 0 @AT@ 72 @LENGTH@ 364\n" +
|
||||
"---DEL if@@if x >= 0 && y >= 0 printf \"%lld %lld %lld %lld\\n\" zero x + y x + y zero @AT@ 146 @LENGTH@ 72\n" +
|
||||
"---UPD if@@if x < 0 && y >= 0 printf \"%lld %lld %lld %lld\\n\" - ( - x + y ) zero zero - x + y elseif if x >= 0 && y < 0 printf \"%lld %lld %lld %lld\\n\" zero - ( x - y ) x - y zero else printf \"%lld %lld %lld %lld\\n\" - ( - x - y ) zero zero - ( - x - y ) @TO@ if x >= 0 && y >= 0 printf \"%lld %lld %lld %lld\\n\" zero x + y x + y zero elseif if x < 0 && y >= 0 printf \"%lld %lld %lld %lld\\n\" - ( - x + y ) zero zero - x + y elseif if x >= 0 && y < 0 printf \"%lld %lld %lld %lld\\n\" zero - ( x - y ) x - y zero else printf \"%lld %lld %lld %lld\\n\" - ( - x - y ) zero zero - ( - x - y ) @AT@ 245 @LENGTH@ 240\n" +
|
||||
"------MOV condition@@x >= 0 && y >= 0 @TO@ if@@if x < 0 && y >= 0 printf \"%lld %lld %lld %lld\\n\" - ( - x + y ) zero zero - x + y elseif if x >= 0 && y < 0 printf \"%lld %lld %lld %lld\\n\" zero - ( x - y ) x - y zero else printf \"%lld %lld %lld %lld\\n\" - ( - x - y ) zero zero - ( - x - y ) @AT@ 146 @LENGTH@ 16\n" +
|
||||
"------MOV then@@printf \"%lld %lld %lld %lld\\n\" zero x + y x + y zero @TO@ if@@if x < 0 && y >= 0 printf \"%lld %lld %lld %lld\\n\" - ( - x + y ) zero zero - x + y elseif if x >= 0 && y < 0 printf \"%lld %lld %lld %lld\\n\" zero - ( x - y ) x - y zero else printf \"%lld %lld %lld %lld\\n\" - ( - x - y ) zero zero - ( - x - y ) @AT@ 165 @LENGTH@ 52\n" +
|
||||
"------INS elseif@@elseif if x < 0 && y >= 0 printf \"%lld %lld %lld %lld\\n\" - ( - x + y ) zero zero - x + y @TO@ if@@if x < 0 && y >= 0 printf \"%lld %lld %lld %lld\\n\" - ( - x + y ) zero zero - x + y elseif if x >= 0 && y < 0 printf \"%lld %lld %lld %lld\\n\" zero - ( x - y ) x - y zero else printf \"%lld %lld %lld %lld\\n\" - ( - x - y ) zero zero - ( - x - y ) @AT@ 250 @LENGTH@ 88\n" +
|
||||
"---------INS if@@if x < 0 && y >= 0 printf \"%lld %lld %lld %lld\\n\" - ( - x + y ) zero zero - x + y @TO@ elseif@@elseif if x < 0 && y >= 0 printf \"%lld %lld %lld %lld\\n\" - ( - x + y ) zero zero - x + y @AT@ 250 @LENGTH@ 81\n" +
|
||||
"------------MOV condition@@x < 0 && y >= 0 @TO@ if@@if x < 0 && y >= 0 printf \"%lld %lld %lld %lld\\n\" - ( - x + y ) zero zero - x + y @AT@ 245 @LENGTH@ 15\n" +
|
||||
"------------MOV then@@printf \"%lld %lld %lld %lld\\n\" - ( - x + y ) zero zero - x + y @TO@ if@@if x < 0 && y >= 0 printf \"%lld %lld %lld %lld\\n\" - ( - x + y ) zero zero - x + y @AT@ 263 @LENGTH@ 62\n");
|
||||
}
|
||||
|
||||
|
||||
//10-A-bug-1998522-1998523
|
||||
@Test
|
||||
public void test_10_A_1998522_1998523() throws IOException {
|
||||
//TODO
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("10-A-1998522-1998523.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(), 1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(), "INS expr_stmt@@lr = r @TO@ block@@scanf \"%d %d\" & l & r e += ( r - l ) * p1 if l - lr <= t1 e += ( l - lr ) * p1 else e += t1 * p1 if l - lr <= t1 + t2 e += ( l - lr - t1 ) * p2 else e += t2 * p2 + ( l - lr - t1 - t2 ) * p3 @AT@ 465 @LENGTH@ 6\n" +
|
||||
"---INS expr@@lr = r @TO@ expr_stmt@@lr = r @AT@ 465 @LENGTH@ 6\n" +
|
||||
"------INS name@@lr @TO@ expr@@lr = r @AT@ 465 @LENGTH@ 2\n" +
|
||||
"------INS operator@@= @TO@ expr@@lr = r @AT@ 468 @LENGTH@ 1\n" +
|
||||
"------INS name@@r @TO@ expr@@lr = r @AT@ 470 @LENGTH@ 1\n");
|
||||
}
|
||||
@Test
|
||||
public void test_328_B_4080800_4080805() throws IOException {
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("328-B-4080800-4080805.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(), 1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(), "DEL for@@for i = 0 i < 10 i ++ printf \"%d %d\\n\" num ][i tnum ][i @AT@ 453 @LENGTH@ 55\n" +
|
||||
"---DEL control@@i = 0 i < 10 i ++ @AT@ 453 @LENGTH@ 17\n" +
|
||||
"------DEL init@@i = 0 @AT@ 454 @LENGTH@ 5\n" +
|
||||
"---------DEL expr@@i = 0 @AT@ 454 @LENGTH@ 5\n" +
|
||||
"------------DEL name@@i @AT@ 454 @LENGTH@ 1\n" +
|
||||
"------------DEL operator@@= @AT@ 455 @LENGTH@ 1\n" +
|
||||
"------------DEL literal:number@@0 @AT@ 456 @LENGTH@ 1\n" +
|
||||
"------DEL condition@@i < 10 @AT@ 458 @LENGTH@ 6\n" +
|
||||
"---------DEL expr@@i < 10 @AT@ 458 @LENGTH@ 6\n" +
|
||||
"------------DEL name@@i @AT@ 458 @LENGTH@ 1\n" +
|
||||
"------------DEL operator@@< @AT@ 459 @LENGTH@ 1\n" +
|
||||
"------------DEL literal:number@@10 @AT@ 460 @LENGTH@ 2\n" +
|
||||
"------DEL incr@@i ++ @AT@ 463 @LENGTH@ 4\n" +
|
||||
"---------DEL expr@@i ++ @AT@ 463 @LENGTH@ 4\n" +
|
||||
"------------DEL name@@i @AT@ 463 @LENGTH@ 1\n" +
|
||||
"------------DEL operator@@++ @AT@ 464 @LENGTH@ 2\n" +
|
||||
"---DEL block@@printf \"%d %d\\n\" num ][i tnum ][i @AT@ 467 @LENGTH@ 33\n" +
|
||||
"------DEL expr_stmt@@printf \"%d %d\\n\" num ][i tnum ][i @AT@ 477 @LENGTH@ 33\n" +
|
||||
"---------DEL expr@@printf \"%d %d\\n\" num ][i tnum ][i @AT@ 477 @LENGTH@ 33\n" +
|
||||
"------------DEL call@@printf \"%d %d\\n\" num ][i tnum ][i @AT@ 477 @LENGTH@ 33\n" +
|
||||
"---------------DEL name@@printf @AT@ 477 @LENGTH@ 6\n" +
|
||||
"---------------DEL argument_list@@\"%d %d\\n\" num ][i tnum ][i @AT@ 483 @LENGTH@ 26\n" +
|
||||
"------------------DEL argument@@\"%d %d\\n\" @AT@ 484 @LENGTH@ 9\n" +
|
||||
"---------------------DEL expr@@\"%d %d\\n\" @AT@ 484 @LENGTH@ 9\n" +
|
||||
"------------------------DEL literal:string@@\"%d %d\\n\" @AT@ 484 @LENGTH@ 9\n" +
|
||||
"------------------DEL argument@@num ][i @AT@ 494 @LENGTH@ 7\n" +
|
||||
"---------------------DEL expr@@num ][i @AT@ 494 @LENGTH@ 7\n" +
|
||||
"------------------------DEL name@@num ][i @AT@ 494 @LENGTH@ 7\n" +
|
||||
"---------------------------DEL name@@num @AT@ 494 @LENGTH@ 3\n" +
|
||||
"---------------------------DEL index@@][i @AT@ 498 @LENGTH@ 3\n" +
|
||||
"------------------------------DEL expr@@[i @AT@ 498 @LENGTH@ 2\n" +
|
||||
"---------------------------------DEL name@@[i @AT@ 498 @LENGTH@ 2\n" +
|
||||
"------------------DEL argument@@tnum ][i @AT@ 501 @LENGTH@ 8\n" +
|
||||
"---------------------DEL expr@@tnum ][i @AT@ 501 @LENGTH@ 8\n" +
|
||||
"------------------------DEL name@@tnum ][i @AT@ 501 @LENGTH@ 8\n" +
|
||||
"---------------------------DEL name@@tnum @AT@ 501 @LENGTH@ 4\n" +
|
||||
"---------------------------DEL index@@][i @AT@ 506 @LENGTH@ 3\n" +
|
||||
"------------------------------DEL expr@@[i @AT@ 506 @LENGTH@ 2\n" +
|
||||
"---------------------------------DEL name@@[i @AT@ 506 @LENGTH@ 2\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_10_A_2106391_2106405() throws IOException {
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("10-A-2106391-2106405.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(), 1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD block@@ @TO@ scanf \"%d %d\" & c & e d = c - b if d >= t1 p += t1 * p1 d -= t1 elseif if d > 0 p += d * p1 d = 0 if d >= t2 p += t2 * p2 d -= t2 elseif if d > 0 p += d * p2 d = 0 if d > 0 p += d * p3 p += p1 * ( e - c ) a = c b = e @AT@ 295 @LENGTH@ 0\n" +
|
||||
"---MOV expr_stmt@@scanf \"%d %d\" & c & e @TO@ block@@ @AT@ 309 @LENGTH@ 21\n" +
|
||||
"---MOV expr_stmt@@d = c - b @TO@ block@@ @AT@ 347 @LENGTH@ 9\n" +
|
||||
"---MOV if@@if d >= t1 p += t1 * p1 d -= t1 elseif if d > 0 p += d * p1 d = 0 @TO@ block@@ @AT@ 372 @LENGTH@ 65\n" +
|
||||
"---MOV if@@if d >= t2 p += t2 * p2 d -= t2 elseif if d > 0 p += d * p2 d = 0 @TO@ block@@ @AT@ 618 @LENGTH@ 65\n" +
|
||||
"---MOV if@@if d > 0 p += d * p3 @TO@ block@@ @AT@ 857 @LENGTH@ 20\n" +
|
||||
"---MOV expr_stmt@@p += p1 * ( e - c ) @TO@ block@@ @AT@ 888 @LENGTH@ 19\n" +
|
||||
"---MOV expr_stmt@@a = c @TO@ block@@ @AT@ 917 @LENGTH@ 5\n" +
|
||||
"---MOV expr_stmt@@b = e @TO@ block@@ @AT@ 938 @LENGTH@ 5\n");
|
||||
}
|
||||
|
||||
//10-A-4557108-4561236
|
||||
@Test
|
||||
public void test_10_A_4557108_4561236() throws IOException {
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("10-A-4557108-4561236.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(), 1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD if@@if m > t1 && m < t2 p += p2 * ( m - t1 ) @TO@ if m > t1 && m - t1 < t2 p += p2 * ( m - t1 ) @AT@ 502 @LENGTH@ 40\n" +
|
||||
"---UPD condition@@m > t1 && m < t2 @TO@ m > t1 && m - t1 < t2 @AT@ 502 @LENGTH@ 16\n" +
|
||||
"------UPD expr@@m > t1 && m < t2 @TO@ m > t1 && m - t1 < t2 @AT@ 503 @LENGTH@ 16\n" +
|
||||
"---------INS operator@@- @TO@ expr@@m > t1 && m < t2 @AT@ 512 @LENGTH@ 1\n" +
|
||||
"---------INS name@@t1 @TO@ expr@@m > t1 && m < t2 @AT@ 513 @LENGTH@ 2\n");
|
||||
}
|
||||
|
||||
//10-A-5914564-5914663
|
||||
@Test
|
||||
public void test_10_A_5914564_5914663() throws IOException {
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("10-A-5914564-5914663.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(), 1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"INS else@@else power += ( a - lr - t1 ) * p2 @TO@ if@@if lr + t1 + t2 <= a power += ( t2 * p2 ) + ( a - lr - t1 - t2 ) * p3 @AT@ 501 @LENGTH@ 34\n" +
|
||||
"---INS block@@power += ( a - lr - t1 ) * p2 @TO@ else@@else power += ( a - lr - t1 ) * p2 @AT@ 501 @LENGTH@ 29\n" +
|
||||
"------INS expr_stmt@@power += ( a - lr - t1 ) * p2 @TO@ block@@power += ( a - lr - t1 ) * p2 @AT@ 501 @LENGTH@ 29\n" +
|
||||
"---------INS expr@@power += ( a - lr - t1 ) * p2 @TO@ expr_stmt@@power += ( a - lr - t1 ) * p2 @AT@ 501 @LENGTH@ 29\n" +
|
||||
"------------INS name@@power @TO@ expr@@power += ( a - lr - t1 ) * p2 @AT@ 501 @LENGTH@ 5\n" +
|
||||
"------------INS operator@@+= @TO@ expr@@power += ( a - lr - t1 ) * p2 @AT@ 506 @LENGTH@ 2\n" +
|
||||
"------------INS operator@@( @TO@ expr@@power += ( a - lr - t1 ) * p2 @AT@ 508 @LENGTH@ 1\n" +
|
||||
"------------INS name@@a @TO@ expr@@power += ( a - lr - t1 ) * p2 @AT@ 509 @LENGTH@ 1\n" +
|
||||
"------------INS operator@@- @TO@ expr@@power += ( a - lr - t1 ) * p2 @AT@ 510 @LENGTH@ 1\n" +
|
||||
"------------INS name@@lr @TO@ expr@@power += ( a - lr - t1 ) * p2 @AT@ 511 @LENGTH@ 2\n" +
|
||||
"------------INS operator@@- @TO@ expr@@power += ( a - lr - t1 ) * p2 @AT@ 513 @LENGTH@ 1\n" +
|
||||
"------------INS name@@t1 @TO@ expr@@power += ( a - lr - t1 ) * p2 @AT@ 514 @LENGTH@ 2\n" +
|
||||
"------------INS operator@@) @TO@ expr@@power += ( a - lr - t1 ) * p2 @AT@ 516 @LENGTH@ 1\n" +
|
||||
"------------INS operator@@* @TO@ expr@@power += ( a - lr - t1 ) * p2 @AT@ 517 @LENGTH@ 1\n" +
|
||||
"------------INS name@@p2 @TO@ expr@@power += ( a - lr - t1 ) * p2 @AT@ 518 @LENGTH@ 2\n");
|
||||
}
|
||||
|
||||
//10-D-1434543-1434549
|
||||
@Test
|
||||
public void test_10_D_1434543_1434549() throws IOException {
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("10-D-1434543-1434549.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(), 1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"INS if@@if max == 0 printf \"0\\n\" continue; @TO@ block@@for i = 0 i < la i ++ scanf \"%d\" & a ][i scanf \"%d\" & lb for i = 0 i < lb i ++ scanf \"%d\" & b ][i memset f 0 f for i = 0 i <= 500 i ++ p ][i = - 1 for i = 1 i <= la i ++ k = 0 for j = 1 j <= lb j ++ if b ][j - 1 < a ][i - 1 && f ][j > f ][k k = j if a ][i - 1 == b ][j - 1 && f ][k >= f ][j f ][j = f ][k + 1 p ][j = k max = 0 int t 1 for i = 1 i <= lb i ++ if max < f ][i max = f ][i t = i int k 0 int d ][501 d ][++ k = b ][t - 1 while 1 t = p ][t if t == 0 break; d ][++ k = b ][t - 1 printf \"%d\\n\" k for i = k i > 1 i -- printf \"%d \" d ][i printf \"%d\\n\" d ][1 @AT@ 692 @LENGTH@ 34\n" +
|
||||
"---INS condition@@max == 0 @TO@ if@@if max == 0 printf \"0\\n\" continue; @AT@ 692 @LENGTH@ 8\n" +
|
||||
"------INS expr@@max == 0 @TO@ condition@@max == 0 @AT@ 693 @LENGTH@ 8\n" +
|
||||
"---------INS name@@max @TO@ expr@@max == 0 @AT@ 693 @LENGTH@ 3\n" +
|
||||
"---------INS operator@@== @TO@ expr@@max == 0 @AT@ 696 @LENGTH@ 2\n" +
|
||||
"---------INS literal:number@@0 @TO@ expr@@max == 0 @AT@ 698 @LENGTH@ 1\n" +
|
||||
"---INS then@@printf \"0\\n\" continue; @TO@ if@@if max == 0 printf \"0\\n\" continue; @AT@ 702 @LENGTH@ 22\n" +
|
||||
"------INS block@@printf \"0\\n\" continue; @TO@ then@@printf \"0\\n\" continue; @AT@ 702 @LENGTH@ 22\n" +
|
||||
"---------INS expr_stmt@@printf \"0\\n\" @TO@ block@@printf \"0\\n\" continue; @AT@ 703 @LENGTH@ 12\n" +
|
||||
"------------INS expr@@printf \"0\\n\" @TO@ expr_stmt@@printf \"0\\n\" @AT@ 703 @LENGTH@ 12\n" +
|
||||
"---------------INS call@@printf \"0\\n\" @TO@ expr@@printf \"0\\n\" @AT@ 703 @LENGTH@ 12\n" +
|
||||
"------------------INS name@@printf @TO@ call@@printf \"0\\n\" @AT@ 703 @LENGTH@ 6\n" +
|
||||
"------------------INS argument_list@@\"0\\n\" @TO@ call@@printf \"0\\n\" @AT@ 709 @LENGTH@ 5\n" +
|
||||
"---------------------INS argument@@\"0\\n\" @TO@ argument_list@@\"0\\n\" @AT@ 710 @LENGTH@ 5\n" +
|
||||
"------------------------INS expr@@\"0\\n\" @TO@ argument@@\"0\\n\" @AT@ 710 @LENGTH@ 5\n" +
|
||||
"---------------------------INS literal:string@@\"0\\n\" @TO@ expr@@\"0\\n\" @AT@ 710 @LENGTH@ 5\n" +
|
||||
"---------INS continue@@continue; @TO@ block@@printf \"0\\n\" continue; @AT@ 717 @LENGTH@ 9\n");
|
||||
}
|
||||
|
||||
//101-A-3317973-3317996
|
||||
@Test
|
||||
public void test_101_A_3317973_3317996() throws IOException {
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("101-A-3317973-3317996.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(), 1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD if@@if sum >= k break; @TO@ if sum > k break; @AT@ 858 @LENGTH@ 18\n" +
|
||||
"---UPD condition@@sum >= k @TO@ sum > k @AT@ 858 @LENGTH@ 8\n" +
|
||||
"------UPD expr@@sum >= k @TO@ sum > k @AT@ 859 @LENGTH@ 8\n" +
|
||||
"---------UPD operator@@>= @TO@ > @AT@ 862 @LENGTH@ 2\n");
|
||||
HierarchicalActionSet actionSet = hierarchicalActionSets.get(0);
|
||||
ITree targetTree = EDiffHelper.getTargets(actionSet,false);
|
||||
ITree actionTree = EDiffHelper.getActionTrees(actionSet);
|
||||
ITree shapeTree = EDiffHelper.getShapeTree(actionSet,false);
|
||||
actionSet.getActionSize();
|
||||
}
|
||||
//102-A-14574020-14574054
|
||||
@Test
|
||||
public void test_102_A_14574020_14574054() throws IOException {
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("102-A-14574020-14574054.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(), 1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD if@@if min printf \"%ld \\n\" min else printf \"%d\" - 1 @TO@ if min != LONG_MAX printf \"%ld \\n\" min else printf \"%d\" - 1 @AT@ 1082 @LENGTH@ 47\n" +
|
||||
"---UPD condition@@min @TO@ min != LONG_MAX @AT@ 1082 @LENGTH@ 3\n" +
|
||||
"------UPD expr@@min @TO@ min != LONG_MAX @AT@ 1084 @LENGTH@ 3\n" +
|
||||
"---------INS operator@@!= @TO@ expr@@min @AT@ 1087 @LENGTH@ 2\n" +
|
||||
"---------INS name@@LONG_MAX @TO@ expr@@min @AT@ 1089 @LENGTH@ 8\n");
|
||||
}
|
||||
|
||||
//102-A-9556179-9556185
|
||||
@Test
|
||||
public void test_102_A_9556179_9556185() throws IOException {
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("102-A-9556179-9556185.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(), 1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD expr_stmt@@b ][x ][y = 1 @TO@ b ][y ][x = b ][x ][y = 1 @AT@ 244 @LENGTH@ 13\n" +
|
||||
"---UPD expr@@b ][x ][y = 1 @TO@ b ][y ][x = b ][x ][y = 1 @AT@ 244 @LENGTH@ 13\n" +
|
||||
"------MOV name@@b ][x ][y @TO@ expr@@b ][x ][y = 1 @AT@ 244 @LENGTH@ 9\n" +
|
||||
"------INS name@@b ][y ][x @TO@ expr@@b ][x ][y = 1 @AT@ 244 @LENGTH@ 9\n" +
|
||||
"---------INS name@@b @TO@ name@@b ][y ][x @AT@ 244 @LENGTH@ 1\n" +
|
||||
"---------INS index@@][y @TO@ name@@b ][y ][x @AT@ 246 @LENGTH@ 3\n" +
|
||||
"------------INS expr@@[y @TO@ index@@][y @AT@ 246 @LENGTH@ 2\n" +
|
||||
"---------------INS name@@[y @TO@ expr@@[y @AT@ 246 @LENGTH@ 2\n" +
|
||||
"---------INS index@@][x @TO@ name@@b ][y ][x @AT@ 249 @LENGTH@ 3\n" +
|
||||
"------------INS expr@@[x @TO@ index@@][x @AT@ 249 @LENGTH@ 2\n" +
|
||||
"---------------INS name@@[x @TO@ expr@@[x @AT@ 249 @LENGTH@ 2\n" +
|
||||
"------INS operator@@= @TO@ expr@@b ][x ][y = 1 @AT@ 262 @LENGTH@ 1\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_254_B_2751488_2751528() throws IOException {
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("254-B-2751488-2751528.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(), 1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD if@@if d <= 0 * m = * m - 1 * d = days ][* m @TO@ if * d <= 0 * m = * m - 1 * d = days ][* m @AT@ 197 @LENGTH@ 40\n" +
|
||||
"---UPD condition@@d <= 0 @TO@ * d <= 0 @AT@ 197 @LENGTH@ 6\n" +
|
||||
"------UPD expr@@d <= 0 @TO@ * d <= 0 @AT@ 198 @LENGTH@ 6\n" +
|
||||
"---------INS operator@@* @TO@ expr@@d <= 0 @AT@ 198 @LENGTH@ 1\n");
|
||||
}
|
||||
|
||||
//codeflaws_430-C-6594918-6595299.c
|
||||
@Test
|
||||
public void test_430_C_6594918_6595299() throws IOException {
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("430-C-6594918-6595299.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(), 1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD block@@stk ][front ++ = nn -> v v ][nn -> v -> c = 0 if cc == 1 val ][nn -> v ++ @TO@ stk ][front ++ = nn -> v v ][nn -> v -> c = 0 val ][nn -> v += val ][stk ][rear @AT@ 1733 @LENGTH@ 73\n" +
|
||||
"---DEL if@@if cc == 1 val ][nn -> v ++ @AT@ 1832 @LENGTH@ 27\n" +
|
||||
"------DEL condition@@cc == 1 @AT@ 1832 @LENGTH@ 7\n" +
|
||||
"---------DEL expr@@cc == 1 @AT@ 1833 @LENGTH@ 7\n" +
|
||||
"------------DEL name@@cc @AT@ 1833 @LENGTH@ 2\n" +
|
||||
"------------DEL operator@@== @AT@ 1835 @LENGTH@ 2\n" +
|
||||
"------------DEL literal:number@@1 @AT@ 1837 @LENGTH@ 1\n" +
|
||||
"------DEL then@@val ][nn -> v ++ @AT@ 1864 @LENGTH@ 16\n" +
|
||||
"---------DEL block@@val ][nn -> v ++ @AT@ 1864 @LENGTH@ 16\n" +
|
||||
"---MOV expr_stmt@@val ][nn -> v ++ @TO@ block@@stk ][front ++ = nn -> v v ][nn -> v -> c = 0 if cc == 1 val ][nn -> v ++ @AT@ 1864 @LENGTH@ 16\n" +
|
||||
"------UPD expr_stmt@@val ][nn -> v ++ @TO@ val ][nn -> v += val ][stk ][rear @AT@ 1864 @LENGTH@ 16\n" +
|
||||
"---------UPD expr@@val ][nn -> v ++ @TO@ val ][nn -> v += val ][stk ][rear @AT@ 1864 @LENGTH@ 16\n" +
|
||||
"------------INS name@@val ][stk ][rear @TO@ expr@@val ][nn -> v ++ @AT@ 1842 @LENGTH@ 16\n" +
|
||||
"---------------INS name@@val @TO@ name@@val ][stk ][rear @AT@ 1842 @LENGTH@ 3\n" +
|
||||
"---------------INS index@@][stk ][rear @TO@ name@@val ][stk ][rear @AT@ 1846 @LENGTH@ 12\n" +
|
||||
"------------------INS expr@@[stk ][rear @TO@ index@@][stk ][rear @AT@ 1846 @LENGTH@ 11\n" +
|
||||
"---------------------INS name@@[stk ][rear @TO@ expr@@[stk ][rear @AT@ 1846 @LENGTH@ 11\n" +
|
||||
"------------------------INS name@@[stk @TO@ name@@[stk ][rear @AT@ 1846 @LENGTH@ 4\n" +
|
||||
"------------------------INS index@@][rear @TO@ name@@[stk ][rear @AT@ 1850 @LENGTH@ 6\n" +
|
||||
"---------------------------INS expr@@[rear @TO@ index@@][rear @AT@ 1850 @LENGTH@ 5\n" +
|
||||
"------------------------------INS name@@[rear @TO@ expr@@[rear @AT@ 1850 @LENGTH@ 5\n" +
|
||||
"------------UPD operator@@++ @TO@ += @AT@ 1874 @LENGTH@ 2\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_496_A_15303159_15303846() throws IOException {
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("496-A-15303159-15303846.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(), 1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"INS expr_stmt@@max = 0 @TO@ block@@for j = 0 j < n - 1 j ++ if i == j + 1 && max < a ][j + 2 - a ][j max = a ][j + 2 - a ][j elseif if max < a ][j + 1 - a ][j max = a ][j + 1 - a ][j b ][i = max @AT@ 155 @LENGTH@ 7\n" +
|
||||
"---INS expr@@max = 0 @TO@ expr_stmt@@max = 0 @AT@ 155 @LENGTH@ 7\n" +
|
||||
"------INS name@@max @TO@ expr@@max = 0 @AT@ 155 @LENGTH@ 3\n" +
|
||||
"------INS operator@@= @TO@ expr@@max = 0 @AT@ 158 @LENGTH@ 1\n" +
|
||||
"------INS literal:number@@0 @TO@ expr@@max = 0 @AT@ 159 @LENGTH@ 1\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_430_B_10625991_10626001() throws IOException {
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("430-B-10625991-10626001.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(), 1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"INS else@@else break; @TO@ if@@if A ][start == A ][end && ( start && A ][start - 1 == A ][end ) && ( end != n - 1 && A ][start == A ][end + 1 ) count2 = 4 , start -= 2 , end += 2 elseif if ( A ][start == A ][end ) && ( start && A ][start - 1 == A ][end ) count2 = 3 , start -= 2 , end += 1 elseif if ( A ][start == A ][end ) && ( end != n - 1 && A ][start == A ][end + 1 ) count2 = 3 , start -= 1 , end += 2 @AT@ 803 @LENGTH@ 11\n" +
|
||||
"---INS block@@break; @TO@ else@@else break; @AT@ 803 @LENGTH@ 6\n" +
|
||||
"------INS break@@break; @TO@ block@@break; @AT@ 803 @LENGTH@ 6\n");
|
||||
}
|
||||
@Test
|
||||
public void test_60_A_510615_510619() throws IOException {
|
||||
//wrong
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("60-A-510615-510619.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(), 1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"INS else@@else break; @TO@ if@@if A ][start == A ][end && ( start && A ][start - 1 == A ][end ) && ( end != n - 1 && A ][start == A ][end + 1 ) count2 = 4 , start -= 2 , end += 2 elseif if ( A ][start == A ][end ) && ( start && A ][start - 1 == A ][end ) count2 = 3 , start -= 2 , end += 1 elseif if ( A ][start == A ][end ) && ( end != n - 1 && A ][start == A ][end + 1 ) count2 = 3 , start -= 1 , end += 2 @AT@ 803 @LENGTH@ 11\n" +
|
||||
"---INS block@@break; @TO@ else@@else break; @AT@ 803 @LENGTH@ 6\n" +
|
||||
"------INS break@@break; @TO@ block@@break; @AT@ 803 @LENGTH@ 6\n");
|
||||
}
|
||||
@Test
|
||||
public void test_509_B_11349359_11354327() throws IOException {
|
||||
//wrong//
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("509-B-11349359-11354327.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(), 1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD ternary@@j < min 1 else j - min + 1 @TO@ j <= min 1 else j - min @AT@ 368 @LENGTH@ 26\n" +
|
||||
"---UPD condition@@j < min @TO@ j <= min @AT@ 368 @LENGTH@ 7\n" +
|
||||
"------UPD expr@@j < min @TO@ j <= min @AT@ 368 @LENGTH@ 7\n" +
|
||||
"---------UPD operator@@< @TO@ <= @AT@ 369 @LENGTH@ 1\n" +
|
||||
"---UPD else@@else j - min + 1 @TO@ else j - min @AT@ 380 @LENGTH@ 16\n" +
|
||||
"------UPD expr@@j - min + 1 @TO@ j - min @AT@ 380 @LENGTH@ 11\n" +
|
||||
"---------DEL operator@@+ @AT@ 385 @LENGTH@ 1\n" +
|
||||
"---------DEL literal:number@@1 @AT@ 386 @LENGTH@ 1\n");
|
||||
}
|
||||
@Test
|
||||
public void test_6_C_12776326_12776346() throws IOException {
|
||||
//wrong//
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("6-C-12776326-12776346.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(), 1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD if@@if n == 1 printf \"1 0\\n\" @TO@ if n == 1 printf \"1 0\\n\" return 0 @AT@ 83 @LENGTH@ 24\n" +
|
||||
"---UPD then@@printf \"1 0\\n\" @TO@ printf \"1 0\\n\" return 0 @AT@ 94 @LENGTH@ 14\n" +
|
||||
"------UPD block@@printf \"1 0\\n\" @TO@ printf \"1 0\\n\" return 0 @AT@ 94 @LENGTH@ 14\n" +
|
||||
"---------MOV return@@return 0 @TO@ block@@printf \"1 0\\n\" @AT@ 111 @LENGTH@ 8\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_494_A_10139010_10139025() throws IOException {
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("494-A-10139010-10139025.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(), 1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD if@@if sum == 0 && h > 0 flag = 0 @TO@ if ( sum == 0 && h > 0 ) || sum - h + 1 <= 0 flag = 0 @AT@ 298 @LENGTH@ 29\n" +
|
||||
"---UPD condition@@sum == 0 && h > 0 @TO@ ( sum == 0 && h > 0 ) || sum - h + 1 <= 0 @AT@ 298 @LENGTH@ 17\n" +
|
||||
"------UPD expr@@sum == 0 && h > 0 @TO@ ( sum == 0 && h > 0 ) || sum - h + 1 <= 0 @AT@ 299 @LENGTH@ 17\n" +
|
||||
"---------INS operator@@( @TO@ expr@@sum == 0 && h > 0 @AT@ 299 @LENGTH@ 1\n" +
|
||||
"---------INS operator@@) @TO@ expr@@sum == 0 && h > 0 @AT@ 313 @LENGTH@ 1\n" +
|
||||
"---------INS operator@@|| @TO@ expr@@sum == 0 && h > 0 @AT@ 315 @LENGTH@ 2\n" +
|
||||
"---------INS name@@sum @TO@ expr@@sum == 0 && h > 0 @AT@ 318 @LENGTH@ 3\n" +
|
||||
"---------INS operator@@- @TO@ expr@@sum == 0 && h > 0 @AT@ 321 @LENGTH@ 1\n" +
|
||||
"---------INS name@@h @TO@ expr@@sum == 0 && h > 0 @AT@ 322 @LENGTH@ 1\n" +
|
||||
"---------INS operator@@+ @TO@ expr@@sum == 0 && h > 0 @AT@ 323 @LENGTH@ 1\n" +
|
||||
"---------INS literal:number@@1 @TO@ expr@@sum == 0 && h > 0 @AT@ 324 @LENGTH@ 1\n" +
|
||||
"---------INS operator@@<= @TO@ expr@@sum == 0 && h > 0 @AT@ 325 @LENGTH@ 2\n" +
|
||||
"---------INS literal:number@@0 @TO@ expr@@sum == 0 && h > 0 @AT@ 327 @LENGTH@ 1\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_248_B_3757114_3757122() throws IOException {
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("248-B-3757114-3757122.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(), 1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD expr_stmt@@printf \"%3d\\n\" suf ][n % P @TO@ printf \"%.*d\\n\" 3 suf ][n % P @AT@ 334 @LENGTH@ 26\n" +
|
||||
"---UPD expr@@printf \"%3d\\n\" suf ][n % P @TO@ printf \"%.*d\\n\" 3 suf ][n % P @AT@ 334 @LENGTH@ 26\n" +
|
||||
"------UPD call@@printf \"%3d\\n\" suf ][n % P @TO@ printf \"%.*d\\n\" 3 suf ][n % P @AT@ 334 @LENGTH@ 26\n" +
|
||||
"---------UPD argument_list@@\"%3d\\n\" suf ][n % P @TO@ \"%.*d\\n\" 3 suf ][n % P @AT@ 341 @LENGTH@ 19\n" +
|
||||
"------------UPD argument@@\"%3d\\n\" @TO@ \"%.*d\\n\" @AT@ 342 @LENGTH@ 7\n" +
|
||||
"---------------UPD expr@@\"%3d\\n\" @TO@ \"%.*d\\n\" @AT@ 342 @LENGTH@ 7\n" +
|
||||
"------------------UPD literal:string@@\"%3d\\n\" @TO@ \"%.*d\\n\" @AT@ 342 @LENGTH@ 7\n" +
|
||||
"------------INS argument@@3 @TO@ argument_list@@\"%3d\\n\" suf ][n % P @AT@ 352 @LENGTH@ 1\n" +
|
||||
"---------------INS expr@@3 @TO@ argument@@3 @AT@ 352 @LENGTH@ 1\n" +
|
||||
"------------------INS literal:number@@3 @TO@ expr@@3 @AT@ 352 @LENGTH@ 1\n");
|
||||
}
|
||||
|
||||
//codeflaws_31-B-14288247-14288278.c
|
||||
@Test
|
||||
public void test_31_B_14288247_14288278() throws IOException {
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = getHierarchicalActionSets("31-B-14288247-14288278.c");
|
||||
Assert.assertEquals(hierarchicalActionSets.size(), 1);
|
||||
Assert.assertEquals(hierarchicalActionSets.get(0).toString(),"UPD expr_stmt@@printf \"%3d\\n\" suf ][n % P @TO@ printf \"%.*d\\n\" 3 suf ][n % P @AT@ 334 @LENGTH@ 26\n" +
|
||||
"---UPD expr@@printf \"%3d\\n\" suf ][n % P @TO@ printf \"%.*d\\n\" 3 suf ][n % P @AT@ 334 @LENGTH@ 26\n" +
|
||||
"------UPD call@@printf \"%3d\\n\" suf ][n % P @TO@ printf \"%.*d\\n\" 3 suf ][n % P @AT@ 334 @LENGTH@ 26\n" +
|
||||
"---------UPD argument_list@@\"%3d\\n\" suf ][n % P @TO@ \"%.*d\\n\" 3 suf ][n % P @AT@ 341 @LENGTH@ 19\n" +
|
||||
"------------UPD argument@@\"%3d\\n\" @TO@ \"%.*d\\n\" @AT@ 342 @LENGTH@ 7\n" +
|
||||
"---------------UPD expr@@\"%3d\\n\" @TO@ \"%.*d\\n\" @AT@ 342 @LENGTH@ 7\n" +
|
||||
"------------------UPD literal:string@@\"%3d\\n\" @TO@ \"%.*d\\n\" @AT@ 342 @LENGTH@ 7\n" +
|
||||
"------------INS argument@@3 @TO@ argument_list@@\"%3d\\n\" suf ][n % P @AT@ 352 @LENGTH@ 1\n" +
|
||||
"---------------INS expr@@3 @TO@ argument@@3 @AT@ 352 @LENGTH@ 1\n" +
|
||||
"------------------INS literal:number@@3 @TO@ expr@@3 @AT@ 352 @LENGTH@ 1\n");
|
||||
}
|
||||
|
||||
public List<HierarchicalActionSet> getHierarchicalActionSets(String s) throws IOException {
|
||||
Properties appProps = new Properties();
|
||||
appProps.load(new FileInputStream("src/main/resource/app.properties"));
|
||||
String srcMLPath = appProps.getProperty("srcMLPath", "FORKJOIN");
|
||||
// String root = appProps.getProperty("inputPath");
|
||||
String root = "src/main/resource/testFiles";
|
||||
root = root + "/codeflaws/";
|
||||
String filename = s;
|
||||
try{
|
||||
File revFile = new File(root + "revFiles/" + filename);
|
||||
File prevFile = new File(root + "prevFiles/prev_" + filename);
|
||||
|
||||
EDiffHunkParser parser = new EDiffHunkParser();
|
||||
|
||||
|
||||
List<HierarchicalActionSet> hierarchicalActionSets = parser.parseChangedSourceCodeWithGumTree2(prevFile, revFile, srcMLPath,false);
|
||||
return hierarchicalActionSets;
|
||||
}catch (NullPointerException n){
|
||||
String cmd = "cp /Users/anil.koyuncu/projects/test/fixminer-data/patches/codeflaws/"+n.getMessage().split(root)[1] + " /Users/anil.koyuncu/projects/test/fixminerC/"+n.getMessage();
|
||||
CallShell cs = new CallShell();
|
||||
try {
|
||||
cs.runShell(cmd);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
package edu.lu.uni.serval.fixminer.jobs;
|
||||
|
||||
import edu.lu.uni.serval.fixminer.ediff.EDiffHunkParser;
|
||||
import edu.lu.uni.serval.utils.CallShell;
|
||||
import edu.lu.uni.serval.utils.EDiffHelper;
|
||||
import edu.lu.uni.serval.utils.PoolBuilder;
|
||||
import me.tongfei.progressbar.ProgressBar;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
|
||||
/**
|
||||
* Created by anilkoyuncu on 03/04/2018.
|
||||
*/
|
||||
public class CompareTrees {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(CompareTrees.class);
|
||||
|
||||
|
||||
public static void main(String redisPath, String portDumps, String dumpsName, String job,String numOfWorkers) throws Exception {
|
||||
|
||||
// shape /Users/anil.koyuncu/projects/test/fixminer-core/python/data/redis ALLdumps-gumInput.rdb clusterl0-gumInputALL.rdb /Users/anil.koyuncu/projects/test/fixminer-core/python/data/richEditScript
|
||||
|
||||
// String portInner = "6380";
|
||||
String port = portDumps; //"6399";
|
||||
CallShell cs = new CallShell();
|
||||
String cmd = "bash "+redisPath + "/" + "startServer.sh" +" %s %s %s";
|
||||
cmd = String.format(cmd, redisPath,dumpsName,Integer.valueOf(port));
|
||||
log.info(cmd);
|
||||
cs.runShell(cmd, port);
|
||||
|
||||
// String cmdInner = "bash "+redisPath + "/" + "startServer.sh" +" %s %s %s";
|
||||
// cmdInner = String.format(cmdInner, redisPath,compareDBName,Integer.valueOf(portInner));
|
||||
// log.info(cmdInner);
|
||||
// cs.runShell(cmdInner, portInner);
|
||||
|
||||
// String numOfWorkers = "100000000";//args[4];
|
||||
// String host = "localhost";//args[5];
|
||||
// -Djava.util.concurrent.ForkJoinPool.common.parallelism=256
|
||||
|
||||
// final JedisPool innerPool = new JedisPool(PoolBuilder.getPoolConfig(), host,Integer.valueOf(portInner),20000000);
|
||||
|
||||
final JedisPool outerPool = new JedisPool(PoolBuilder.getPoolConfig(), "localhost",Integer.valueOf(port),20000000);
|
||||
|
||||
// List<String> listOfPairs = AkkaTreeParser.getMessages(innerPool,Integer.valueOf(numOfWorkers));
|
||||
HashMap<String, String> filenames = getFilenames(outerPool);
|
||||
// List<String> listOfPairs = AkkaTreeParser.files2compare(outerPool);
|
||||
|
||||
|
||||
// ArrayList<String> samePairs = new ArrayList<>();
|
||||
ArrayList<String> errorPairs = new ArrayList<>();
|
||||
|
||||
// Integer numberOfWorkers = Integer.valueOf(numOfWorkers);
|
||||
// final ExecutorService executor = Executors.newWorkStealingPool(numberOfWorkers);
|
||||
Long compare;
|
||||
try (Jedis inner = outerPool.getResource()) {
|
||||
compare = inner.scard("compare");
|
||||
}
|
||||
IntStream stream = IntStream.range(0, compare.intValue());
|
||||
|
||||
ProgressBar.wrap(stream.
|
||||
parallel(),"Task").
|
||||
|
||||
forEach(m ->
|
||||
{
|
||||
newCoreCompare(job, errorPairs, filenames, outerPool);
|
||||
}
|
||||
);
|
||||
|
||||
//
|
||||
// ArrayList<Future<?>> results = new ArrayList<Future<?>>();
|
||||
// for (int i = 0; i <numberOfWorkers ; i++) {
|
||||
//
|
||||
//
|
||||
// // schedule the work
|
||||
// log.info("Starting job {}",i);
|
||||
// final Future<?> future = executor.submit(new RunnableCompare(job, errorPairs, filenames, outerPool, i));
|
||||
// results.add(future);
|
||||
// }
|
||||
// for (Future<?> future : ProgressBar.wrap(results, "Comparing")){
|
||||
//// for (Future<?> future:results){
|
||||
// try {
|
||||
// // wait for task to complete
|
||||
// future.get();
|
||||
//
|
||||
// } catch (InterruptedException e) {
|
||||
//
|
||||
// e.printStackTrace();
|
||||
// } catch (ExecutionException e) {
|
||||
//
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//// finally {
|
||||
//// executor.shutdownNow();
|
||||
//// }
|
||||
// }
|
||||
// executor.shutdownNow();
|
||||
|
||||
|
||||
|
||||
|
||||
log.info("End process");
|
||||
}
|
||||
|
||||
|
||||
// public static class RunnableCompare implements Runnable {
|
||||
// String job;
|
||||
// ArrayList<String> errorPairs;
|
||||
// HashMap<String, String> filenames;
|
||||
// JedisPool outerPool;
|
||||
// Integer threadID;
|
||||
//
|
||||
// public RunnableCompare(String treeType,ArrayList<String> errorPairs, HashMap<String, String> filenames,JedisPool outerPool,Integer threadID) {
|
||||
// this.job = treeType;
|
||||
// this.errorPairs = errorPairs;
|
||||
// this.filenames = filenames;
|
||||
// this.outerPool = outerPool;
|
||||
// this.threadID = threadID;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void run() {
|
||||
//// int dbsize = 1;
|
||||
// boolean stop = true;
|
||||
// while(stop) {
|
||||
//// try (Jedis outer = outerPool.getResource()) {
|
||||
//// dbsize = Math.toIntExact(outer.scard("compare"));
|
||||
//// }
|
||||
//// if (dbsize != 0){
|
||||
// stop = newCoreCompare(job, errorPairs, filenames, outerPool);
|
||||
//// }
|
||||
// }
|
||||
// log.info("Completed worker {}",threadID);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public static boolean newCoreCompare( String treeType,ArrayList<String> errorPairs, HashMap<String, String> filenames,JedisPool outerPool ) {
|
||||
|
||||
String pairName;
|
||||
try (Jedis outer = outerPool.getResource()) {
|
||||
pairName = outer.spop("compare");
|
||||
}
|
||||
|
||||
String matchKey = null;
|
||||
try {
|
||||
|
||||
String[] split = pairName.split("/");
|
||||
|
||||
|
||||
String i = split[1];
|
||||
String j = split[2];
|
||||
String keyName = split[0];
|
||||
matchKey = keyName + "/" + (String.valueOf(i)) + "/" + String.valueOf(j);
|
||||
|
||||
switch (treeType) {
|
||||
case "single":
|
||||
|
||||
if (matchKey == null){
|
||||
return false;
|
||||
}
|
||||
Map<String, String> oldTreeString = EDiffHelper.getTreeString(keyName, i, outerPool, filenames);
|
||||
Map<String, String> newTreeString = EDiffHelper.getTreeString(keyName, j, outerPool, filenames);
|
||||
|
||||
String oldShapeTree =oldTreeString.get("shapeTree");
|
||||
String newShapeTree =newTreeString.get("shapeTree");
|
||||
|
||||
String oldActionTree = oldTreeString.get("actionTree");
|
||||
String newActionTree = newTreeString.get("actionTree");
|
||||
|
||||
String oldTargetTree = oldTreeString.get("targetTree");
|
||||
String newTargetTree = newTreeString.get("targetTree");
|
||||
|
||||
|
||||
if (oldShapeTree.equals(newShapeTree)) {
|
||||
if (oldActionTree.equals(newActionTree)) {
|
||||
if (oldTargetTree.equals(newTargetTree)) {
|
||||
// samePairs.add(matchKey);
|
||||
try (Jedis jedis = outerPool.getResource()) {
|
||||
//// jedis.del(matchKey);
|
||||
jedis.select(2);
|
||||
jedis.set(matchKey, "1");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return true;
|
||||
// break;
|
||||
}
|
||||
}catch (Exception e) {
|
||||
errorPairs.add(matchKey);
|
||||
if (pairName == null)
|
||||
return false;
|
||||
log.debug("{} not comparable", pairName);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static HashMap<String, String> getFilenames(JedisPool innerPool){
|
||||
|
||||
|
||||
HashMap<String, String> fileMap =new HashMap<String, String>();
|
||||
|
||||
try (Jedis inner = innerPool.getResource()) {
|
||||
while (!inner.ping().equals("PONG")){
|
||||
log.info("wait");
|
||||
}
|
||||
|
||||
inner.select(1);
|
||||
Map<String, String> filenames = inner.hgetAll("filenames");
|
||||
|
||||
|
||||
for (Map.Entry<String, String> stringStringEntry : filenames.entrySet().stream().collect(Collectors.toList())) {
|
||||
fileMap.put(stringStringEntry.getKey(),stringStringEntry.getValue());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// log.info("Getting results %d",fileMap.s);
|
||||
return fileMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,22 +1,24 @@
|
||||
package edu.lu.uni.serval.fixminer.jobs;
|
||||
|
||||
import akka.actor.ActorRef;
|
||||
import akka.actor.ActorSystem;
|
||||
import edu.lu.uni.serval.fixminer.akka.ediff.EDiffActor;
|
||||
import edu.lu.uni.serval.fixminer.akka.ediff.EDiffHunkParser;
|
||||
import edu.lu.uni.serval.fixminer.akka.ediff.EDiffMessage;
|
||||
import edu.lu.uni.serval.fixminer.akka.ediff.MessageFile;
|
||||
import edu.lu.uni.serval.utils.CallShell;
|
||||
import edu.lu.uni.serval.fixminer.ediff.EDiffHunkParser;
|
||||
import edu.lu.uni.serval.utils.FileHelper;
|
||||
import edu.lu.uni.serval.fixminer.ediff.MessageFile;
|
||||
import edu.lu.uni.serval.utils.CallShell;
|
||||
import edu.lu.uni.serval.utils.PoolBuilder;
|
||||
import me.tongfei.progressbar.ProgressBar;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -24,7 +26,7 @@ public class EnhancedASTDiff {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(EnhancedASTDiff.class);
|
||||
|
||||
public static void main(String inputPath, String numOfWorkers, String project, String eDiffTimeout, String parallelism, String portInner, String dbDir, String chunkName) throws Exception {
|
||||
public static void main(String inputPath, String portInner, String dbDir, String chunkName,String srcMLPath,String parameter,String hunkLimit,String[] projectList,String patchSize,String projectType) throws Exception {
|
||||
|
||||
|
||||
String parameters = String.format("\nInput path %s",inputPath);
|
||||
@@ -32,26 +34,54 @@ public class EnhancedASTDiff {
|
||||
|
||||
CallShell cs = new CallShell();
|
||||
String cmd = "bash "+dbDir + "/" + "startServer.sh" +" %s %s %s";
|
||||
|
||||
cmd = String.format(cmd, dbDir,chunkName,Integer.valueOf(portInner));
|
||||
|
||||
cs.runShell(cmd, portInner);
|
||||
|
||||
JedisPool innerPool = new JedisPool(PoolBuilder.getPoolConfig(), "127.0.0.1",Integer.valueOf(portInner),20000000);
|
||||
|
||||
boolean isJava = false;
|
||||
if (projectType.equals("java")){
|
||||
isJava =true;
|
||||
}
|
||||
File folder = new File(inputPath);
|
||||
File[] listOfFiles = folder.listFiles();
|
||||
Stream<File> stream = Arrays.stream(listOfFiles);
|
||||
List<File> folders = stream
|
||||
List<File> folders;
|
||||
if (projectList.length == 1 && projectList[0].equals("")){
|
||||
folders = stream
|
||||
.filter(x -> !x.getName().startsWith("."))
|
||||
.filter(x -> !x.getName().startsWith("cocci"))
|
||||
.filter(x -> !x.getName().endsWith(".index"))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
else {
|
||||
List<Predicate<File>> allPredicates = new ArrayList<Predicate<File>>();
|
||||
for (String s : projectList) {
|
||||
Predicate<File> predicate = x -> x.getName().endsWith(s);
|
||||
allPredicates.add(predicate);
|
||||
}
|
||||
folders = stream
|
||||
.filter(x -> !x.getName().startsWith("."))
|
||||
.filter(x -> !x.getName().startsWith("cocci"))
|
||||
.filter(x -> !x.getName().endsWith(".index"))
|
||||
.filter(allPredicates.stream().reduce(x->false, Predicate::or))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
String project = folder.getName();
|
||||
List<MessageFile> allMessageFiles = new ArrayList<>();
|
||||
for (File target : folders) {
|
||||
|
||||
List<MessageFile> msgFiles = getMessageFiles(target.toString() + "/"); //"/Users/anilkoyuncu/bugStudy/code/python/GumTreeInput/Apache/CAMEL/"
|
||||
|
||||
List<MessageFile> msgFiles = getMessageFiles(target.toString() + "/",project,patchSize,isJava); //"/Users/anilkoyuncu/bugStudy/code/python/GumTreeInput/Apache/CAMEL/"
|
||||
|
||||
// msgFiles = msgFiles.subList(0,3000);
|
||||
if (msgFiles == null)
|
||||
continue;
|
||||
allMessageFiles.addAll(msgFiles);
|
||||
@@ -59,76 +89,69 @@ public class EnhancedASTDiff {
|
||||
|
||||
}
|
||||
|
||||
switch (parallelism){
|
||||
case "AKKA":
|
||||
ActorSystem system = null;
|
||||
ActorRef parsingActor = null;
|
||||
final EDiffMessage msg = new EDiffMessage(0, allMessageFiles,eDiffTimeout,innerPool);
|
||||
try {
|
||||
log.info("Akka begins...");
|
||||
log.info("{} files to process ...", allMessageFiles.size());
|
||||
system = ActorSystem.create("Mining-FixPattern-System");
|
||||
Map<String, String> diffEntry;
|
||||
try (Jedis inner = innerPool.getResource()) {
|
||||
diffEntry = inner.hgetAll("diffEntry");
|
||||
|
||||
parsingActor = system.actorOf(EDiffActor.props(Integer.valueOf(numOfWorkers), project), "mine-fix-pattern-actor");
|
||||
parsingActor.tell(msg, ActorRef.noSender());
|
||||
} catch (Exception e) {
|
||||
system.shutdown();
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
case "FORKJOIN":
|
||||
int counter = new Object() {
|
||||
int counter = 0;
|
||||
|
||||
{
|
||||
allMessageFiles.stream().
|
||||
parallel().
|
||||
peek(x -> counter++).
|
||||
log.info("{} files to process ...", allMessageFiles.size());
|
||||
if (diffEntry != null) {
|
||||
log.info("{} files already process ...", diffEntry.size());
|
||||
allMessageFiles = allMessageFiles.stream().filter(f -> !diffEntry.containsKey(f.getProject() + "_" + f.getDiffEntryFile().getName())).collect(Collectors.toList());
|
||||
log.info("{} files to process ...", allMessageFiles.size());
|
||||
}
|
||||
boolean finalIsJava = isJava;
|
||||
ProgressBar.wrap(allMessageFiles.stream().
|
||||
parallel(),"Task").
|
||||
forEach(m ->
|
||||
{
|
||||
EDiffHunkParser parser = new EDiffHunkParser();
|
||||
parser.parseFixPatterns(m.getPrevFile(),m.getRevFile(), m.getDiffEntryFile(),project,innerPool);
|
||||
if (counter % 10 == 0) {
|
||||
log.info("Finalized parsing " + counter + " files... remaining " + (allMessageFiles.size() - counter));
|
||||
}
|
||||
parser.parseFixPatterns(m.getPrevFile(),m.getRevFile(), m.getDiffEntryFile(),project,innerPool,srcMLPath,hunkLimit, finalIsJava);
|
||||
}
|
||||
);
|
||||
}
|
||||
}.counter;
|
||||
log.info("Finished parsing {} files",counter);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
log.error("Unknown parallelism {}", parallelism);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static List<MessageFile> getMessageFiles(String gumTreeInput) {
|
||||
private static List<MessageFile> getMessageFiles(String gumTreeInput,String datasetName,String patchSize,boolean isJava) {
|
||||
String inputPath = gumTreeInput; // prevFiles revFiles diffentryFile positionsFile
|
||||
File revFilesPath = new File(inputPath + "revFiles/");
|
||||
log.info(revFilesPath.getPath());
|
||||
File[] revFiles = revFilesPath.listFiles();
|
||||
if (revFiles!= null ){
|
||||
// List<File> collect = Arrays.stream(revFiles).filter(x -> x.getName().startsWith("b50867_6e80c3_src#main#java#org#apache#hadoop#hbase#regionserver#HRegion"))
|
||||
// List<File> collect = Arrays.stream(revFiles).filter(x -> x.getName().startsWith("0a2756_7598f8_components#camel-cxf#src#main#java#org#apache#camel#component#cxf#CxfHeaderFilterStrategy"))
|
||||
// .collect(Collectors.toList());// project folders
|
||||
List<MessageFile> msgFiles = new ArrayList<>();
|
||||
for (File revFile : revFiles) {
|
||||
// for (File revFile : collect) {
|
||||
String fileName = revFile.getName();
|
||||
File prevFile = new File(gumTreeInput + "prevFiles/prev_" + fileName);// previous file
|
||||
fileName = fileName.replace(".java", ".txt");
|
||||
if (isJava){
|
||||
fileName = fileName.replace(".java",".txt");
|
||||
}else{
|
||||
fileName = fileName + ".txt";
|
||||
}
|
||||
File diffentryFile = new File(gumTreeInput + "DiffEntries/" + fileName); // DiffEntry file
|
||||
String s = FileHelper.readFile(diffentryFile);
|
||||
|
||||
MessageFile msgFile = new MessageFile(revFile, prevFile, diffentryFile);
|
||||
Pattern pattern = Pattern.compile("^[\\+|\\-]\\s*",Pattern.MULTILINE);
|
||||
Matcher matcher = pattern.matcher(s);
|
||||
int count = 0;
|
||||
while (matcher.find())
|
||||
count++;
|
||||
if(count>= Integer.valueOf(patchSize))
|
||||
// if(count>201)
|
||||
continue;
|
||||
// if(FileHelper.readFile(diffentryFile).split("@@\\s\\-\\d+,*\\d*\\s\\+\\d+,*\\d*\\s@@").length > 2)
|
||||
// continue;
|
||||
|
||||
// String datasetName = project;
|
||||
String[] split1 = diffentryFile.getParent().split(datasetName);
|
||||
String root = split1[0];
|
||||
String pj = split1[1].split("/")[1];
|
||||
|
||||
MessageFile msgFile = new MessageFile(revFile, prevFile, diffentryFile,pj);
|
||||
|
||||
msgFiles.add(msgFile);
|
||||
|
||||
@@ -141,4 +164,5 @@ public class EnhancedASTDiff {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package edu.lu.uni.serval.utils;
|
||||
|
||||
import edu.lu.uni.serval.fixminer.akka.ediff.HierarchicalActionSet;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import redis.clients.jedis.Jedis;
|
||||
@@ -30,12 +29,12 @@ public class ClusterToPattern {
|
||||
while (!outer.ping().equals("PONG")) {
|
||||
log.info("wait");
|
||||
}
|
||||
byte[] s = outer.hget("dump".getBytes(), filename.getBytes());
|
||||
HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.kryoDeseerialize(s);
|
||||
if (actionSet == null){
|
||||
throw new Error(filename +" not found");
|
||||
}
|
||||
String s1 = actionSet.toString();
|
||||
// byte[] s = outer.hget("dump".getBytes(), filename.getBytes());
|
||||
// HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.kryoDeseerialize(s);
|
||||
// if (actionSet == null){
|
||||
// throw new Error(filename +" not found");
|
||||
// }
|
||||
String s1 = outer.hget("dump",filename);
|
||||
// outer.close();
|
||||
return s1;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package edu.lu.uni.serval.utils;
|
||||
|
||||
import com.github.gumtreediff.actions.model.*;
|
||||
import com.github.gumtreediff.gen.srcml.NodeMap_new;
|
||||
import com.github.gumtreediff.tree.ITree;
|
||||
import com.github.gumtreediff.tree.TreeContext;
|
||||
import com.github.gumtreediff.tree.TreeUtils;
|
||||
import edu.lu.uni.serval.fixminer.akka.ediff.DefaultKryoContext;
|
||||
import edu.lu.uni.serval.fixminer.akka.ediff.HierarchicalActionSet;
|
||||
import edu.lu.uni.serval.fixminer.akka.ediff.KryoContext;
|
||||
import org.javatuples.Pair;
|
||||
import edu.lu.uni.serval.fixminer.ediff.HierarchicalActionSet;
|
||||
import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import redis.clients.jedis.Jedis;
|
||||
@@ -63,17 +62,15 @@ public class EDiffHelper {
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
|
||||
public static byte[] kryoSerialize(Serializable o ){
|
||||
KryoContext kryoContext = DefaultKryoContext.newKryoContextFactory();
|
||||
return kryoContext.serialze(o);
|
||||
public static byte[] commonsSerialize(Serializable o){
|
||||
return SerializationUtils.serialize(o);
|
||||
}
|
||||
|
||||
public static Object kryoDeseerialize(byte[] data ){
|
||||
KryoContext kryoContext = DefaultKryoContext.newKryoContextFactory();
|
||||
return kryoContext.deserialze(HierarchicalActionSet.class,data);
|
||||
public static Object commonsDeserialize(byte[] data){
|
||||
return SerializationUtils.deserialize(data);
|
||||
}
|
||||
|
||||
|
||||
public static ITree getTokenTree(HierarchicalActionSet actionSet, ITree parent, ITree children,TreeContext tc){
|
||||
|
||||
int newType = 0;
|
||||
@@ -81,7 +78,8 @@ public class EDiffHelper {
|
||||
String astNodeType = actionSet.getAstNodeType();
|
||||
|
||||
String label = actionSet.getAction().toString();
|
||||
List<Integer> keysByValue = getKeysByValue(ASTNodeMap.map, astNodeType);
|
||||
// List<Integer> keysByValue = getKeysByValue(ASTNodeMap.map, astNodeType);
|
||||
List<Integer> keysByValue = getKeysByValue(NodeMap_new.map, astNodeType);
|
||||
|
||||
if(keysByValue.size() != 1){
|
||||
log.error("More than 1");
|
||||
@@ -115,16 +113,23 @@ public class EDiffHelper {
|
||||
|
||||
|
||||
|
||||
public static ITree getTargetTree(HierarchicalActionSet actionSet, ITree parent, ITree children, TreeContext tc){
|
||||
public static ITree getTargetTree(HierarchicalActionSet actionSet, ITree parent, ITree children, TreeContext tc,boolean isJava){
|
||||
|
||||
int newType = 0;
|
||||
|
||||
String astNodeType = null;
|
||||
Map<Integer, String> nodeMap;
|
||||
if(isJava){
|
||||
nodeMap = ASTNodeMap.map;
|
||||
}else{
|
||||
nodeMap = NodeMap_new.map;
|
||||
}
|
||||
|
||||
Action action = actionSet.getAction();
|
||||
if (action instanceof Update){
|
||||
astNodeType = actionSet.getAstNodeType();
|
||||
List<Integer> keysByValue = getKeysByValue(ASTNodeMap.map, astNodeType);
|
||||
|
||||
List<Integer> keysByValue = getKeysByValue(nodeMap, astNodeType);
|
||||
|
||||
if(keysByValue.size() != 1){
|
||||
log.error("More than 1");
|
||||
@@ -136,7 +141,8 @@ public class EDiffHelper {
|
||||
newType = ((Move)action).getParent().getType();
|
||||
}else if(action instanceof Delete){
|
||||
astNodeType = actionSet.getAstNodeType();
|
||||
List<Integer> keysByValue = getKeysByValue(ASTNodeMap.map, astNodeType);
|
||||
|
||||
List<Integer> keysByValue = getKeysByValue(nodeMap, astNodeType);
|
||||
|
||||
if(keysByValue.size() != 1){
|
||||
log.error("More than 1");
|
||||
@@ -165,7 +171,7 @@ public class EDiffHelper {
|
||||
if(actionSet.getParent() == null){
|
||||
children = parent;
|
||||
}
|
||||
getTargetTree(subAction,children,null,tc);
|
||||
getTargetTree(subAction,children,null,tc,isJava);
|
||||
|
||||
}
|
||||
|
||||
@@ -174,12 +180,18 @@ public class EDiffHelper {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public static ITree getASTTree(HierarchicalActionSet actionSet, ITree parent, ITree children, TreeContext tc){
|
||||
public static ITree getASTTree(HierarchicalActionSet actionSet, ITree parent, ITree children, TreeContext tc,boolean isJava){
|
||||
|
||||
int newType = 0;
|
||||
|
||||
Map<Integer, String> nodeMap;
|
||||
if(isJava){
|
||||
nodeMap = ASTNodeMap.map;
|
||||
}else{
|
||||
nodeMap = NodeMap_new.map;
|
||||
}
|
||||
String astNodeType = actionSet.getAstNodeType();
|
||||
List<Integer> keysByValue = getKeysByValue(ASTNodeMap.map, astNodeType);
|
||||
|
||||
List<Integer> keysByValue = getKeysByValue(nodeMap, astNodeType);
|
||||
|
||||
if(keysByValue.size() != 1){
|
||||
log.error("More than 1");
|
||||
@@ -204,7 +216,7 @@ public class EDiffHelper {
|
||||
if(actionSet.getParent() == null){
|
||||
children = parent;
|
||||
}
|
||||
getASTTree(subAction,children,null,tc);
|
||||
getASTTree(subAction,children,null,tc,isJava);
|
||||
|
||||
}
|
||||
|
||||
@@ -222,75 +234,81 @@ public class EDiffHelper {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static ITree getSimpliedTree(String prefix, String fn, JedisPool outerPool) {
|
||||
// public static ITree getSimpliedTree(String prefix, String fn, JedisPool outerPool) {
|
||||
//
|
||||
// ITree tree = null;
|
||||
// Jedis inner = null;
|
||||
// try {
|
||||
// inner = outerPool.getResource();
|
||||
// while (!inner.ping().equals("PONG")){
|
||||
// log.info("wait");
|
||||
// }
|
||||
// inner.select(1);
|
||||
// String dist2load = inner.get(prefix+"-"+fn);
|
||||
// inner.select(0);
|
||||
// String s = inner.get(prefix.replace("-","/") +"/"+dist2load);
|
||||
// HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.fromString(s);
|
||||
//
|
||||
// ITree parent = null;
|
||||
// ITree children =null;
|
||||
// TreeContext tc = new TreeContext();
|
||||
// tree = EDiffHelper.getASTTree(actionSet, parent, children,tc);
|
||||
// tree.setParent(null);
|
||||
// tc.validate();
|
||||
//
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (ClassNotFoundException e) {
|
||||
// e.printStackTrace();
|
||||
// }finally {
|
||||
// if (inner != null) {
|
||||
// inner.close();
|
||||
// }
|
||||
// }
|
||||
// return tree;
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
// public static ITree getShapes(String prefix, String fn, JedisPool outerPool, HashMap<String, String> filenames) {
|
||||
//
|
||||
// ITree tree = null;
|
||||
//
|
||||
// try (Jedis outer = outerPool.getResource()) {
|
||||
// try {
|
||||
// while (!outer.ping().equals("PONG")) {
|
||||
// log.info("wait");
|
||||
// }
|
||||
// String dist2load = filenames.get(prefix + "-" + fn);
|
||||
//
|
||||
// String key = prefix.replace("-", "/") + "/" + dist2load;
|
||||
//
|
||||
// byte[] s = outer.hget("dump".getBytes(), key.getBytes());
|
||||
// HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.kryoDeseerialize(s);
|
||||
//
|
||||
// tree = getShapeTree(actionSet);
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// return tree;
|
||||
//
|
||||
// }
|
||||
|
||||
public static ITree getShapeTree(HierarchicalActionSet actionSet,boolean isJava) {
|
||||
ITree tree = null;
|
||||
Jedis inner = null;
|
||||
try {
|
||||
inner = outerPool.getResource();
|
||||
while (!inner.ping().equals("PONG")){
|
||||
log.info("wait");
|
||||
}
|
||||
inner.select(1);
|
||||
String dist2load = inner.get(prefix+"-"+fn);
|
||||
inner.select(0);
|
||||
String s = inner.get(prefix.replace("-","/") +"/"+dist2load);
|
||||
HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.fromString(s);
|
||||
|
||||
ITree parent = null;
|
||||
ITree children =null;
|
||||
TreeContext tc = new TreeContext();
|
||||
tree = EDiffHelper.getASTTree(actionSet, parent, children,tc);
|
||||
tree.setParent(null);
|
||||
tc.validate();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if (inner != null) {
|
||||
inner.close();
|
||||
}
|
||||
}
|
||||
return tree;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static ITree getShapes(String prefix, String fn, JedisPool outerPool, HashMap<String, String> filenames) {
|
||||
|
||||
ITree tree = null;
|
||||
|
||||
try (Jedis outer = outerPool.getResource()) {
|
||||
try {
|
||||
while (!outer.ping().equals("PONG")) {
|
||||
log.info("wait");
|
||||
}
|
||||
String dist2load = filenames.get(prefix + "-" + fn);
|
||||
|
||||
String key = prefix.replace("-", "/") + "/" + dist2load;
|
||||
|
||||
byte[] s = outer.hget("dump".getBytes(), key.getBytes());
|
||||
HierarchicalActionSet actionSet = (HierarchicalActionSet) EDiffHelper.kryoDeseerialize(s);
|
||||
|
||||
ITree parent = null;
|
||||
ITree children = null;
|
||||
TreeContext tc = new TreeContext();
|
||||
tree = EDiffHelper.getASTTree(actionSet, parent, children, tc);
|
||||
tree = EDiffHelper.getASTTree(actionSet, parent, children, tc, isJava);
|
||||
//tree.setParent(null);
|
||||
tc.validate();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return tree;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static ITree getTargets(HierarchicalActionSet actionSet) {
|
||||
public static ITree getTargets(HierarchicalActionSet actionSet,boolean isJava) {
|
||||
|
||||
ITree tree = null;
|
||||
try {
|
||||
@@ -298,7 +316,7 @@ public class EDiffHelper {
|
||||
ITree parent = null;
|
||||
ITree children =null;
|
||||
TreeContext tc = new TreeContext();
|
||||
tree = EDiffHelper.getTargetTree(actionSet, parent, children,tc);
|
||||
tree = EDiffHelper.getTargetTree(actionSet, parent, children,tc,isJava);
|
||||
//tree.setParent(null);
|
||||
tc.validate();
|
||||
} catch (Exception e) {
|
||||
@@ -308,13 +326,7 @@ public class EDiffHelper {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static Pair<ITree,HierarchicalActionSet> getActions(String prefix, String fn, JedisPool outerPool, HashMap<String, String> filenames) {
|
||||
|
||||
|
||||
ITree tree = null;
|
||||
HierarchicalActionSet actionSet = null;
|
||||
|
||||
public static Map<String, String> getTreeString(String prefix, String fn, JedisPool outerPool, HashMap<String, String> filenames) {
|
||||
try (Jedis outer = outerPool.getResource()) {
|
||||
try {
|
||||
while (!outer.ping().equals("PONG")) {
|
||||
@@ -325,26 +337,58 @@ public class EDiffHelper {
|
||||
String dist2load = filenames.get(prefix + "-" + fn);
|
||||
|
||||
String[] split = prefix.split("-");
|
||||
String key = split[0] + "/"+split[1]+"/" + dist2load;
|
||||
|
||||
byte[] s = outer.hget("dump".getBytes(), key.getBytes());
|
||||
actionSet = (HierarchicalActionSet) EDiffHelper.kryoDeseerialize(s);
|
||||
String key = split[0] + "/" + split[1] + "/" + dist2load;
|
||||
Map<String, String> treeMap = outer.hgetAll(key);
|
||||
return treeMap;
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// public static Pair<ITree,HierarchicalActionSet> getActions(String prefix, String fn, JedisPool outerPool, HashMap<String, String> filenames) {
|
||||
//
|
||||
//
|
||||
// ITree tree = null;
|
||||
// HierarchicalActionSet actionSet = null;
|
||||
//
|
||||
// try (Jedis outer = outerPool.getResource()) {
|
||||
// try {
|
||||
// while (!outer.ping().equals("PONG")) {
|
||||
// log.info("wait");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// String dist2load = filenames.get(prefix + "-" + fn);
|
||||
//
|
||||
// String[] split = prefix.split("-");
|
||||
// String key = split[0] + "/"+split[1]+"/" + dist2load;
|
||||
//
|
||||
// byte[] s = outer.hget("dump".getBytes(), key.getBytes());
|
||||
// actionSet = (HierarchicalActionSet) EDiffHelper.kryoDeseerialize(s);
|
||||
//
|
||||
//
|
||||
// tree = getActionTrees(actionSet);
|
||||
// }catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Pair<ITree, HierarchicalActionSet> pair = new Pair<>(tree,actionSet);
|
||||
// return pair;
|
||||
//
|
||||
// }
|
||||
|
||||
public static ITree getActionTrees(HierarchicalActionSet actionSet) {
|
||||
ITree tree = null;
|
||||
ITree parent = null;
|
||||
ITree children = null;
|
||||
TreeContext tc = new TreeContext();
|
||||
tree = EDiffHelper.getActionTree(actionSet, parent, children, tc);
|
||||
//tree.setParent(null);
|
||||
tc.validate();
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Pair<ITree, HierarchicalActionSet> pair = new Pair<>(tree,actionSet);
|
||||
return pair;
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
public static void getLeaves(ITree tc){
|
||||
@@ -360,41 +404,41 @@ public class EDiffHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public static ITree getTokens(String prefix, String fn, JedisPool outerPool, HashMap<String, String> filenames) {
|
||||
|
||||
|
||||
ITree tree = null;
|
||||
|
||||
HierarchicalActionSet actionSet = null;
|
||||
try (Jedis outer = outerPool.getResource()) {
|
||||
try {
|
||||
while (!outer.ping().equals("PONG")) {
|
||||
log.info("wait");
|
||||
}
|
||||
String dist2load = filenames.get(prefix + "-" + fn);
|
||||
|
||||
String[] split = prefix.split("-");
|
||||
String key = split[0] + "/"+split[1]+"/" + dist2load;
|
||||
|
||||
byte[] s = outer.hget("dump".getBytes(), key.getBytes());
|
||||
actionSet = (HierarchicalActionSet) EDiffHelper.kryoDeseerialize(s);
|
||||
|
||||
ITree parent = null;
|
||||
ITree children = null;
|
||||
TreeContext tc = new TreeContext();
|
||||
tree = EDiffHelper.getTokenTree(actionSet, parent, children, tc);
|
||||
tree.setParent(null);
|
||||
tc.validate();
|
||||
// getLeaves(tree);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return tree;
|
||||
}
|
||||
// public static ITree getTokens(String prefix, String fn, JedisPool outerPool, HashMap<String, String> filenames) {
|
||||
//
|
||||
//
|
||||
// ITree tree = null;
|
||||
//
|
||||
// HierarchicalActionSet actionSet = null;
|
||||
// try (Jedis outer = outerPool.getResource()) {
|
||||
// try {
|
||||
// while (!outer.ping().equals("PONG")) {
|
||||
// log.info("wait");
|
||||
// }
|
||||
// String dist2load = filenames.get(prefix + "-" + fn);
|
||||
//
|
||||
// String[] split = prefix.split("-");
|
||||
// String key = split[0] + "/"+split[1]+"/" + dist2load;
|
||||
//
|
||||
// byte[] s = outer.hget("dump".getBytes(), key.getBytes());
|
||||
// actionSet = (HierarchicalActionSet) EDiffHelper.kryoDeseerialize(s);
|
||||
//
|
||||
// ITree parent = null;
|
||||
// ITree children = null;
|
||||
// TreeContext tc = new TreeContext();
|
||||
// tree = EDiffHelper.getTokenTree(actionSet, parent, children, tc);
|
||||
// tree.setParent(null);
|
||||
// tc.validate();
|
||||
//// getLeaves(tree);
|
||||
//
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return tree;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,383 @@
|
||||
package edu.lu.uni.serval.utils;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FileHelper {
|
||||
|
||||
/**
|
||||
* @param filePath
|
||||
*/
|
||||
public static void createDirectory(String filePath) {
|
||||
File file = new File(filePath);
|
||||
if (file.exists()) {
|
||||
deleteDirectory(filePath);
|
||||
}
|
||||
file.mkdirs();
|
||||
}
|
||||
|
||||
public static void createFile(File file, String content) {
|
||||
FileWriter writer = null;
|
||||
BufferedWriter bw = null;
|
||||
|
||||
try {
|
||||
if (!file.getParentFile().exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
if (!file.exists()) file.createNewFile();
|
||||
writer = new FileWriter(file);
|
||||
bw = new BufferedWriter(writer);
|
||||
bw.write(content);
|
||||
bw.flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
close(bw);
|
||||
close(writer);
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteDirectory(String dir) {
|
||||
File file = new File(dir);
|
||||
|
||||
if (file.exists()) {
|
||||
if (file.isDirectory()) {
|
||||
File[] files = file.listFiles();
|
||||
if (files.length > 0) {
|
||||
for (File f : files) {
|
||||
if (f.isFile()) {
|
||||
deleteFile(f.getAbsolutePath());
|
||||
} else {
|
||||
deleteDirectory(f.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
file.delete();
|
||||
} else {
|
||||
deleteFile(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteFiles(String dir) {
|
||||
File file = new File(dir);
|
||||
|
||||
if (file.exists()) {
|
||||
if (file.isDirectory()) {
|
||||
File[] files = file.listFiles();
|
||||
if (files.length > 0) {
|
||||
for (File f : files) {
|
||||
if (f.isFile()) {
|
||||
deleteFile(f.getAbsolutePath());
|
||||
} else {
|
||||
deleteFiles(f.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
deleteFile(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteFile(String fileName) {
|
||||
File file = new File(fileName);
|
||||
|
||||
if (file.exists()) {
|
||||
if (file.isFile()) {
|
||||
file.delete();
|
||||
} else {
|
||||
deleteDirectory(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static List<File> getAllDirectories(String filePath) {
|
||||
return listAllDirectories(new File(filePath));
|
||||
}
|
||||
|
||||
/**
|
||||
* List all files in the directory.
|
||||
*
|
||||
* @param filePath
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public static List<File> getAllFiles(String filePath, String type) {
|
||||
return listAllFiles(new File(filePath), type);
|
||||
}
|
||||
|
||||
public static List<File> getAllFilesInCurrentDiectory(String filePath, String type) {
|
||||
return getAllFilesInCurrentDiectory(new File(filePath), type);
|
||||
}
|
||||
|
||||
public static List<File> getAllFilesInCurrentDiectory(File directory, String type) {
|
||||
List<File> fileList = new ArrayList<>();
|
||||
|
||||
if (!directory.exists()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
File[] files = directory.listFiles();
|
||||
|
||||
for (File file : files) {
|
||||
if (file.isFile()) {
|
||||
if (file.toString().endsWith(type)) {
|
||||
fileList.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fileList;
|
||||
}
|
||||
|
||||
public static String getFileName(String filePath) {
|
||||
File file = new File(filePath);
|
||||
|
||||
if (file.exists()) {
|
||||
return file.getName();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getFileNameWithoutExtension(File file) {
|
||||
if (file.exists()) {
|
||||
String fileName = file.getName();
|
||||
fileName = fileName.substring(0, fileName.lastIndexOf("."));
|
||||
return fileName;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getFileExtension(File file) {
|
||||
String fileName = file.getName();
|
||||
String extension = fileName.substring(fileName.lastIndexOf("."));
|
||||
return extension;
|
||||
}
|
||||
|
||||
public static String getFileParentPath(String filePath) {
|
||||
File file = new File(filePath);
|
||||
|
||||
if (file.exists()) {
|
||||
return file.getParent() + "/";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a file path is valid or not.
|
||||
*
|
||||
* @param path, file path.
|
||||
* @return true, the file path is valid.
|
||||
* false, the file path is invalid.
|
||||
*/
|
||||
public static boolean isValidPath(String path) {
|
||||
File file = new File(path);
|
||||
|
||||
if (file.exists()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively list all files in file.
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
private static List<File> listAllFiles(File file, String type) {
|
||||
List<File> fileList = new ArrayList<>();
|
||||
|
||||
if (!file.exists()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
File[] files = file.listFiles();
|
||||
|
||||
for (File f : files) {
|
||||
if (f.isFile()) {
|
||||
if (f.toString().endsWith(type)) {
|
||||
fileList.add(f);
|
||||
}
|
||||
} else {
|
||||
List<File> fl = listAllFiles(f, type);
|
||||
if (fl != null && fl.size() > 0) {
|
||||
fileList.addAll(fl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fileList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively list all directories in file.
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
private static List<File> listAllDirectories(File file) {
|
||||
List<File> fileList = new ArrayList<>();
|
||||
|
||||
File[] files = file.listFiles();
|
||||
|
||||
for (File f : files) {
|
||||
if (f.isDirectory()) {
|
||||
fileList.add(f);
|
||||
fileList.addAll(listAllDirectories(f));
|
||||
}
|
||||
}
|
||||
|
||||
return fileList;
|
||||
}
|
||||
|
||||
public static void makeDirectory(String fileName) {
|
||||
deleteFile(fileName);
|
||||
File file = new File(fileName).getParentFile();
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the content of a file.
|
||||
*
|
||||
* @param fileName
|
||||
* @return String, the content of a file.
|
||||
*/
|
||||
public static String readFile(String fileName) {
|
||||
return readFile(new File(fileName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the content of a file.
|
||||
*
|
||||
* @param file
|
||||
* @return String, the content of a file.
|
||||
*/
|
||||
public static String readFile(File file) {
|
||||
byte[] input = null;
|
||||
BufferedInputStream bis = null;
|
||||
|
||||
try {
|
||||
|
||||
bis = new BufferedInputStream(new FileInputStream(file));
|
||||
input = new byte[bis.available()];
|
||||
bis.read(input);
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
close(bis);
|
||||
}
|
||||
|
||||
String sourceCode = null;
|
||||
if (input != null) {
|
||||
sourceCode = new String(input);
|
||||
}
|
||||
|
||||
return sourceCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output output into a file.
|
||||
*
|
||||
* @param fileName, output file name.
|
||||
* @param data, output data.
|
||||
* @param append, the output data will be appended previous data in the file or not.
|
||||
*/
|
||||
public static void outputToFile(String fileName, StringBuilder data, boolean append) {
|
||||
outputToFile(fileName, data.toString(), append);
|
||||
}
|
||||
|
||||
public static void outputToFile(File file, StringBuilder data, boolean append) {
|
||||
outputToFile(file, data.toString(), append);
|
||||
}
|
||||
|
||||
public static void outputToFile(String fileName, String data, boolean append) {
|
||||
File file = new File(fileName);
|
||||
outputToFile(file, data, append);
|
||||
}
|
||||
|
||||
public static void outputToFile(File file, String data, boolean append) {
|
||||
FileWriter writer = null;
|
||||
BufferedWriter bw = null;
|
||||
|
||||
try {
|
||||
if (!file.getParentFile().exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
writer = new FileWriter(file, append);
|
||||
bw = new BufferedWriter(writer);
|
||||
bw.write(data);
|
||||
bw.flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
close(bw);
|
||||
close(writer);
|
||||
}
|
||||
}
|
||||
|
||||
private static void close(FileWriter writer) {
|
||||
try {
|
||||
if (writer != null) {
|
||||
writer.close();
|
||||
writer = null;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void close(BufferedWriter bw) {
|
||||
try {
|
||||
if (bw != null) {
|
||||
bw.close();
|
||||
bw = null;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void close(BufferedInputStream bis) {
|
||||
try {
|
||||
if (bis != null) {
|
||||
bis.close();
|
||||
bis = null;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<File> getAllSubDirectories(String fileName) {
|
||||
File file = new File(fileName);
|
||||
List<File> subDirectories = new ArrayList<>();
|
||||
if (file.exists()) {
|
||||
File[] files = file.listFiles();
|
||||
for (File f : files) {
|
||||
if (f.isDirectory()) {
|
||||
subDirectories.add(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
return subDirectories;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package edu.lu.uni.serval.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class ListSorter<T extends Comparable<? super T>> {
|
||||
|
||||
private List<T> list;
|
||||
|
||||
public ListSorter(List<T> list) {
|
||||
this.list = new ArrayList<>();
|
||||
this.list.addAll(list);
|
||||
}
|
||||
|
||||
public List<T> getList() {
|
||||
return this.list;
|
||||
}
|
||||
|
||||
public List<T> sortAscending() {
|
||||
try {
|
||||
if (list != null && list.size() > 0) {
|
||||
Collections.sort(this.list, new Comparator<T>() {
|
||||
|
||||
@Override
|
||||
public int compare(T t1, T t2) {
|
||||
return t1.compareTo(t2);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
return this.list;
|
||||
}
|
||||
|
||||
public List<T> sortDescending() {
|
||||
if (list != null && list.size() > 0) {
|
||||
Collections.sort(this.list, Collections.reverseOrder());
|
||||
}
|
||||
return this.list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
portDumps = 6399
|
||||
numOfWorkers = 14
|
||||
hunkLimit = 10
|
||||
patchSize = 50
|
||||
|
||||
projectList =
|
||||
#projectList = libtiff,php-src,cpython,wireshark,gzip,gmp,lighttpd1.4,lighttpd2
|
||||
|
||||
#inputPath = /Users/anilkoyuncu/projects/gumInputLinux
|
||||
#inputPath = /Users/anil.koyuncu/projects/fixminer/fixminer-data/gumInputLinux
|
||||
inputPath = /Users/anil.koyuncu/projects/test/fixminer-data/patches
|
||||
#redisPath = /Users/anil.koyuncu/projects/fixminer/fixminer-core/python/data/redis
|
||||
#redisPath = /Users/anil.koyuncu/projects/fixminer/fixminer-core/python/data/redis
|
||||
redisPath = /Users/anil.koyuncu/projects/test/fixminer-core/python/data/redis
|
||||
#srcMLPath= /Users/anil.koyuncu/Downloads/srcML.0.9.5/bin/srcml
|
||||
srcMLPath= /Users/anil.koyuncu/projects/test/srcML/bin/srcml
|
||||
#ENHANCEDASTDIFF,CACHE,LEVEL1,LEVEL2,LEVEL3
|
||||
projectType = c
|
||||
|
||||
@@ -1,14 +1,23 @@
|
||||
jobType = LEVEL2
|
||||
pjName = BugsDotJar
|
||||
portInner = 6380
|
||||
dbNo = 0
|
||||
port = 6399
|
||||
serverWait = 10000
|
||||
numOfWorkers = 100
|
||||
pythonPath = /Users/anilkoyuncu/bugStudy/code/python
|
||||
datasetPath = /Users/anilkoyuncu/bugStudy/release/code
|
||||
actionType =UPD
|
||||
threshold = 9
|
||||
|
||||
pjName = patches
|
||||
portDumps = 6399
|
||||
numOfWorkers = 14
|
||||
hostname = localhost
|
||||
hunkLimit = 10
|
||||
patchSize = 50
|
||||
|
||||
projectList = libtiff,php-src,cpython,wireshark,gzip,gmp,lighttpd1.4,lighttpd2
|
||||
|
||||
#inputPath = /Users/anilkoyuncu/projects/gumInputLinux
|
||||
#inputPath = /Users/anil.koyuncu/projects/fixminer/fixminer-data/gumInputLinux
|
||||
inputPath = /Users/anil.koyuncu/projects/test/fixminer-data/patches
|
||||
#redisPath = /Users/anil.koyuncu/projects/fixminer/fixminer-core/python/data/redis
|
||||
#redisPath = /Users/anil.koyuncu/projects/fixminer/fixminer-core/python/data/redis
|
||||
redisPath = /Users/anil.koyuncu/projects/test/fixminer-core/python/data/redis
|
||||
#srcMLPath= /Users/anil.koyuncu/Downloads/srcML.0.9.5/bin/srcml
|
||||
srcMLPath= /Users/anil.koyuncu/projects/test/srcML/bin/srcml
|
||||
#srcMLPath= /usr/local/bin/srcml
|
||||
actionType = ALL
|
||||
|
||||
#ENHANCEDASTDIFF,CACHE,LEVEL1,LEVEL2,LEVEL3
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int p1, p2, p3, t1, t2, n, lr, l, r, e = 0;
|
||||
|
||||
scanf("%d %d %d %d %d %d", &n, &p1, &p2, &p3, &t1, &t2);
|
||||
|
||||
scanf("%d %d", &l, &r);
|
||||
e += (r - l) * p1;
|
||||
lr = r;
|
||||
|
||||
while(-- n)
|
||||
{
|
||||
scanf("%d %d", &l, &r);
|
||||
e += (r - l) * p1;
|
||||
if(l - lr <= t1)
|
||||
e += (l - lr) * p1;
|
||||
else
|
||||
{
|
||||
e += t1 * p1;
|
||||
if(l - lr <= t1 + t2)
|
||||
e += (l - lr - t1) * p2;
|
||||
else
|
||||
e += t2 * p2 + (l - lr - t1 - t2) * p3;
|
||||
}
|
||||
}
|
||||
|
||||
printf("%d\n", e);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int n,p1,p2,p3,t1,t2,a,c,b,e,i,d=0;
|
||||
long int p=0;
|
||||
scanf("%d%d%d%d%d%d",&n,&p1,&p2,&p3,&t1,&t2);
|
||||
scanf("%d %d",&a,&b);
|
||||
if(n==1) p=(b-a)*p1;
|
||||
else { p=(b-a)*p1;
|
||||
for(i=1;i<n;i++);
|
||||
scanf("%d %d",&c,&e);
|
||||
d=c-b;
|
||||
if(d>=t1) {p+=t1*p1;
|
||||
d-=t1;
|
||||
}
|
||||
else if(d>0) {p+=d*p1;
|
||||
d=0;
|
||||
}
|
||||
if(d>=t2) {p+=t2*p2;
|
||||
d-=t2;
|
||||
}
|
||||
else if(d>0) {p+=d*p2;
|
||||
d=0;
|
||||
}
|
||||
if(d>0) p+=d*p3;
|
||||
p+=p1*(e-c);
|
||||
a=c;
|
||||
b=e;
|
||||
}
|
||||
printf("%ld",p);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int i,n,m,p1,p2,p3,t1,t2,l,r,p,s,t,ar[2][101];
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
scanf("%d%d%d%d%d%d",&n,&p1,&p2,&p3,&t1,&t2);
|
||||
|
||||
for (i=0; i<n; i++){
|
||||
scanf("%d%d",&l,&r);
|
||||
ar[0][i]=l;
|
||||
ar[1][i]=r;
|
||||
}
|
||||
|
||||
i=0;
|
||||
while (i<=n){
|
||||
s=ar[1][i]-ar[0][i];
|
||||
p+=s*p1;
|
||||
if (n>=i+1 && ar[0][i+1]-ar[1][i]>0){
|
||||
m=ar[0][i+1]-ar[1][i];
|
||||
if (m>=t1){p+=p1*t1;} else {p+=p1*m;}
|
||||
if (m-t1>=t2){p+=p2*t2;} else if (m>t1 && m<t2) {p+=p2*(m-t1);}
|
||||
if (m-t1>t2){p+=p3*(m-(t2+t1));}
|
||||
}
|
||||
t=ar[1][i];
|
||||
i++;
|
||||
}
|
||||
|
||||
printf("%d",p);
|
||||
return(0);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int n,p1,p2,p3,t1,t2,a,b,i,lr=0,power=0;
|
||||
scanf("%d %d %d %d %d %d",&n,&p1,&p2,&p3,&t1,&t2);
|
||||
scanf("%d %d",&a,&b);
|
||||
power+=(b-a)*p1;
|
||||
lr=b;
|
||||
for(i=1;i<n;i++)
|
||||
{
|
||||
scanf("%d %d",&a,&b);
|
||||
power+=(b-a)*p1;
|
||||
if(lr+t1<=a)
|
||||
{
|
||||
power+=(t1*p1);
|
||||
if(lr+t1+t2<=a)
|
||||
power+=(t2*p2)+(a-lr-t1-t2)*p3;
|
||||
}
|
||||
else
|
||||
power+=(a-lr)*p1;
|
||||
lr=b;
|
||||
}
|
||||
printf("%d",power);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int a[505],b[505],la,lb,f[505],p[505];
|
||||
int i,j,n,k,max;
|
||||
|
||||
|
||||
|
||||
while
|
||||
(scanf("%d",&la)!=EOF)
|
||||
{
|
||||
for(i=0;i<la;i++)
|
||||
scanf("%d",&a[i]);
|
||||
scanf("%d",&lb);
|
||||
for(i=0;i<lb;i++)
|
||||
scanf("%d",&b[i]);
|
||||
memset(f,0,sizeof(f));
|
||||
for(i=0;i<=500;i++)
|
||||
p[i]=-1;
|
||||
for(i=1;i<=la;i++)
|
||||
{
|
||||
k=0;
|
||||
for(j=1;j<=lb;j++)
|
||||
{
|
||||
if(b[j-1]<a[i-1]&&f[j]>f[k])//b[j-1]<a[i-1]是递增的条件,f[j]>f[k]是存放到 j时,j前面的最长的子序列
|
||||
k=j;
|
||||
if(a[i-1]==b[j-1]&&f[k]>=f[j])//逐步优化,要掌握
|
||||
{f[j]=f[k]+1;
|
||||
p[j]=k;
|
||||
}
|
||||
}
|
||||
}
|
||||
max=0;
|
||||
int t=1;
|
||||
for(i=1;i<=lb;i++)
|
||||
{
|
||||
if(max<f[i]) {max=f[i];t=i;}
|
||||
}
|
||||
int k=0;
|
||||
int d[501];
|
||||
|
||||
d[++k]=b[t-1];
|
||||
while(1)
|
||||
{
|
||||
t=p[t];
|
||||
if(t==0)
|
||||
break;
|
||||
d[++k]=b[t-1];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
printf("%d\n",k);
|
||||
for(i=k;i>1;i--)
|
||||
printf("%d ",d[i]);
|
||||
printf("%d\n",d[1]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
char arr[100005];
|
||||
int k;
|
||||
struct string
|
||||
{
|
||||
int index[100005];
|
||||
int character;
|
||||
}e[251];
|
||||
static int age_comp(const void *p1, const void *p2)
|
||||
{
|
||||
struct string *sp1 = (struct string *) p1;
|
||||
struct string *sp2 = (struct string *) p2;
|
||||
|
||||
return sp1->character - sp2->character;
|
||||
}
|
||||
|
||||
void solve();
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
scanf("%s",arr);
|
||||
scanf("%d",&k);
|
||||
solve();
|
||||
return 0;
|
||||
}
|
||||
void solve()
|
||||
{
|
||||
int d,l,i,sum=0,j,m,dst=0,t=0;
|
||||
l=strlen(arr);
|
||||
|
||||
for(i=0;i<=250;i++)
|
||||
e[i].character=0;
|
||||
if(k>=l)
|
||||
{
|
||||
printf("0\n");
|
||||
printf("\0");
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i=0;i<l;i++)
|
||||
{
|
||||
d=arr[i];
|
||||
//printf("%d",d);
|
||||
e[d].index[e[d].character]=i;
|
||||
e[d].character++;
|
||||
}
|
||||
qsort(e,250,sizeof e[0],age_comp);
|
||||
m=0;
|
||||
while(e[m].character==0)
|
||||
m++;
|
||||
for(i=0;i<=250;i++)
|
||||
{
|
||||
if(e[i].character!=0)
|
||||
dst++;
|
||||
}
|
||||
for(i=m;i<=(m+26);i++)
|
||||
{
|
||||
if(e[i].character!=0)
|
||||
{
|
||||
sum+=e[i].character;
|
||||
if(sum>=k)
|
||||
break;
|
||||
t++;
|
||||
for(j=0;j<e[i].character;j++)
|
||||
{
|
||||
arr[e[i].index[j]]='?';
|
||||
}
|
||||
}
|
||||
}
|
||||
//printf("%d",t);
|
||||
dst=dst-t;
|
||||
printf("%d\n",dst);
|
||||
for(i=0;i<l;i++)
|
||||
{
|
||||
if(arr[i]!='?')
|
||||
printf("%c",arr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#define MAX 101
|
||||
//
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
int m , n;
|
||||
int i , j , k ;
|
||||
int x , y; //temp
|
||||
long min = LONG_MAX ;
|
||||
scanf("%d %d",&n,&m);
|
||||
int pairs[MAX][MAX] = {0} ; //bool array
|
||||
int clothesPrices[n];
|
||||
|
||||
// clothesPrices[m] inputs..
|
||||
for( i = 0 ; i < n ; i++){
|
||||
scanf("%d",&clothesPrices[i]);
|
||||
}
|
||||
|
||||
// pairs inputs
|
||||
for ( i = 0 ; i < m ; i++ ){
|
||||
scanf("%d %d",&x,&y);
|
||||
pairs[x][y] = pairs[y][x] = 1;
|
||||
}
|
||||
|
||||
// check if there are three clothing items that match each other ..
|
||||
for ( i = 1 ; i < n ; i++){
|
||||
for ( j = i + 1 ; j <= n ; j++){
|
||||
for ( k = j + 1 ; k <= n ; k++ ){
|
||||
if ( pairs[i][j] && pairs[j][k] && pairs[k][i] ){
|
||||
if ( clothesPrices[i-1]+clothesPrices[j-1]+clothesPrices[k-1] < min ){
|
||||
min = clothesPrices[i-1]+clothesPrices[j-1]+clothesPrices[k-1];
|
||||
//printf("%ld",min);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( min )
|
||||
printf("%ld \n",min);
|
||||
else printf("%d",-1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#include<stdio.h>
|
||||
int a[100005];
|
||||
int b[105][105];
|
||||
int n,i,j,k,x,ans,m;
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int hi ;
|
||||
ans = 40000000;
|
||||
int n;
|
||||
scanf("%d%d",&n,&m);
|
||||
for(i=1;i<=n;i++)
|
||||
scanf("%d",&a[i]);
|
||||
int x,y;
|
||||
for(i=0;i<m;i++)
|
||||
{
|
||||
scanf("%d%d",&x,&y);
|
||||
b[x][y] = 1;
|
||||
}
|
||||
hi = ans;
|
||||
|
||||
for(i=1;i<=n;i++)
|
||||
for(j=i+1;j<=n;j++)
|
||||
for(k=j+1;k<=n;k++)
|
||||
{
|
||||
if(b[i][j] && b[j][k] && b[k][i]){
|
||||
x = a[i] + a[j] + a[k];
|
||||
if(x<ans)ans = x;}
|
||||
}
|
||||
if(ans==hi)ans = -1;
|
||||
printf("%d\n",ans);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
#include <stdio.h>
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i, flag=0, r1, r2, c1, c2, d1, d2, a, b, c, d, ar[1000];
|
||||
scanf("%d %d %d %d %d %d", &r1, &r2, &c1, &c2, &d1, &d2);
|
||||
for(a=1; a<(r1%10); a++)
|
||||
{
|
||||
//printf("a=%d ", a);
|
||||
for(i=1; i<=1000; i++)
|
||||
ar[i]=0;
|
||||
ar[a]=1;
|
||||
if(a>=c1 || a>=d1)
|
||||
{
|
||||
//printf("continuing when a=%d\n", a);
|
||||
continue;
|
||||
}
|
||||
b=r1-a;
|
||||
if(ar[b]==1)
|
||||
continue;
|
||||
else
|
||||
ar[b]=1;
|
||||
if(b>=c2 || b>=d2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
c=c1-a;
|
||||
if(ar[c]==1)
|
||||
continue;
|
||||
else
|
||||
ar[c]=1;
|
||||
if(c>=r2 || c>=d2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
d=d1-a;
|
||||
if(ar[d]==1)
|
||||
continue;
|
||||
if(d>=r2 || d>=c2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(b+c!=d2)
|
||||
continue;
|
||||
if(b+d!=c2)
|
||||
continue;
|
||||
if(c+d!=r2)
|
||||
continue;
|
||||
if(a>9 || b>9 || c>9 || d>9)
|
||||
continue;
|
||||
flag=1;
|
||||
break;
|
||||
//}
|
||||
}
|
||||
if(flag==1)
|
||||
printf("%d %d\n%d %d\n", a, b, c, d);
|
||||
else
|
||||
printf("-1\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#include<stdio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int n,k,x,i,count=0;
|
||||
scanf("%d %d",&n,&k);
|
||||
int ara[n];
|
||||
for(i=0;i<n;i++)
|
||||
{
|
||||
scanf("%d",&ara[i]);
|
||||
}
|
||||
for(i=0;i<n;i++)
|
||||
{
|
||||
if(ara[i]>=ara[k-1])
|
||||
count++;
|
||||
}
|
||||
printf("%d",count);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
/*
|
||||
int main(int argc, char *argv[])
|
||||
{ int n,k,l=0,i,a[50];
|
||||
scanf("%d %d",&n,&k);
|
||||
for(i=1;i<=n;i++)
|
||||
scanf("%d",&a[i]);
|
||||
if(a[1]!=0){
|
||||
l=k;
|
||||
while(l<n){
|
||||
if(a[l]==a[l+1]){
|
||||
l++;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}}
|
||||
printf("%d",l);
|
||||
|
||||
return 0;
|
||||
}*/
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
int n,k,a[50],count,i;
|
||||
scanf("%d %d",&n,&k);
|
||||
for(i=1;i<=n;i++){
|
||||
scanf("%d",&a[i]);
|
||||
}
|
||||
count=0;
|
||||
if(a[1]>0){
|
||||
i=1;
|
||||
while(a[i]>=a[k]&&i<=n){
|
||||
count++;
|
||||
i++;
|
||||
}}
|
||||
printf("%d\n",count);
|
||||
return 0;}
|
||||
@@ -0,0 +1,21 @@
|
||||
#include "stdio.h"
|
||||
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
#define max(a,b) ((a)>(b)?(a):(b))
|
||||
|
||||
int dp[4005], n, k, t, d, i, ans;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
scanf( "%d%d", &n, &k );
|
||||
while(n--)
|
||||
{
|
||||
scanf( "%d%d", &t, &d );
|
||||
ans = max( ans, t - 1 - dp[k] );
|
||||
for( i = k; i >= 1; i-- ) dp[i] = min( dp[i-1], max( dp[i], t-1 ) + d );
|
||||
dp[0] = max( dp[0], t - 1 ) + d;
|
||||
}
|
||||
ans = max( ans, 86401 - dp[k] );
|
||||
printf( "%d\n", ans );
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
int comp(const void *p1, const void *p2) {
|
||||
int n1, n2;
|
||||
n1 = *((const int *)p1);
|
||||
n2 = *((const int *)p2);
|
||||
return n1 - n2;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
int *array;
|
||||
int i,j,k,n,x;
|
||||
int first,last,flg,num;
|
||||
scanf("%d %d",&n,&x);
|
||||
array=(int *)calloc(n,sizeof(int));
|
||||
for(i=0;i<n;i++) scanf("%d",array+i);
|
||||
qsort(array,n,sizeof(int),comp);
|
||||
|
||||
flg=0;
|
||||
for(first=0;first<n;first++){
|
||||
if(array[first]==x){
|
||||
flg=1;
|
||||
break;
|
||||
}else if(array[first]>x){
|
||||
first--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
first++;
|
||||
|
||||
for(last=n-1;last>=0;last--){
|
||||
if(array[last]==x){
|
||||
flg=1;
|
||||
break;
|
||||
}else if(array[last]<x){
|
||||
last++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(last==-1) last++;
|
||||
last++;
|
||||
|
||||
if(flg){
|
||||
if(array[(n+1)/2]==x) printf("0\n");
|
||||
else if(last<(n+1)/2) printf("%d\n",n-2*last);
|
||||
else if(first>(n+1)/2) printf("%d\n",2*first-n-1);
|
||||
}else{
|
||||
k=last;
|
||||
if(k==(n+1)/2) printf("1\n");
|
||||
else if(k>(n+1)/2) printf("%d\n",2*k-n-1);
|
||||
else printf("%d\n",n+2-2*k);
|
||||
}
|
||||
free(array);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// int num[101][101];
|
||||
int i,j,k,n,sum;
|
||||
int a, mid;
|
||||
sum = 0;
|
||||
|
||||
scanf("%d",&n);
|
||||
|
||||
for(i=1;i<=n;i++)
|
||||
{
|
||||
for(j=1;j<=n;j++)
|
||||
{
|
||||
scanf("%d",&a);
|
||||
if(i==j)
|
||||
sum += a;
|
||||
if(j==(n+1)/2)
|
||||
sum += a;
|
||||
if(i==(n+1)/2)
|
||||
sum += a;
|
||||
if(i+j == n+1)
|
||||
sum += a;
|
||||
if(i==(n-1)/2 && j==(n-1)/2)
|
||||
mid = a;
|
||||
}
|
||||
}
|
||||
sum -= (3*mid);
|
||||
printf("%d\n",sum);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
typedef long long ll;
|
||||
|
||||
void func(int w, int h) {
|
||||
ll ans = 0, i, j, k, t;
|
||||
for (i = 1; i < w; i ++) {
|
||||
for (j = 1; j < h; j ++) {
|
||||
k = i;
|
||||
k = MIN(k, w - i);
|
||||
t = j;
|
||||
k = MIN(k, h - j);
|
||||
ans += k * t;
|
||||
}
|
||||
}
|
||||
printf("%lld\n", ans);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int w, h;
|
||||
while (scanf("%d%d", &w, &h) == 2) {
|
||||
func(w, h);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#include <stdio.h>
|
||||
#define MIN(i,j) i<j?i:j
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i,j,w,h,a,b,min;
|
||||
double count=0;
|
||||
scanf("%d %d",&w,&h);
|
||||
min = MIN(w,h);
|
||||
for(a=2;a<=w;a+=2){
|
||||
for(b=2;b<=w;b+=2)
|
||||
{
|
||||
count+=(w-a+1)*(h-b+1);
|
||||
}
|
||||
}
|
||||
printf("%.0lf\n",count);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#include <stdio.h>
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int n, m, i, a[101], b[101];
|
||||
scanf("%d %d", &n, &m);
|
||||
for(i=0; i<=n; i++)
|
||||
scanf("%d", &a[i]);
|
||||
for(i=0; i<=m; i++)
|
||||
scanf("%d", &b[i]);
|
||||
if(n>m)
|
||||
{
|
||||
int prod=a[0]*b[0];
|
||||
if(prod>0)
|
||||
printf("Infinity\n");
|
||||
else
|
||||
printf("-Infinity\n");
|
||||
}
|
||||
else if(n==m)
|
||||
{
|
||||
//printf("a[0]=%d b[0]=%d\n", a[0], b[0]);
|
||||
if((a[0]<0 && b[0]>0) || (a[0]>0 && b[0]<0))
|
||||
printf("-");
|
||||
a[0]=abs(a[0]);
|
||||
b[0]=abs(b[0]);
|
||||
int min=a[0];
|
||||
if(b[0]<min)
|
||||
min=b[0];
|
||||
//printf("a[0]=%d b[0]=%d\n", a[0], b[0]);
|
||||
for(i=2; i<=min; i++)
|
||||
{
|
||||
if(a[0]%i==0 && b[0]%i==0)
|
||||
{
|
||||
a[0]/=i;
|
||||
b[0]/=i;
|
||||
}
|
||||
}
|
||||
printf("%d/%d\n", a[0], b[0]);
|
||||
}
|
||||
else if(n<m)
|
||||
{
|
||||
printf("0/1\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
#include<stdio.h>
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int a;
|
||||
while(scanf("%d",&a)!=EOF)
|
||||
{
|
||||
if(a<=101)
|
||||
printf("%d\n",a);
|
||||
else if(a==123)
|
||||
printf("113\n");
|
||||
else if(a==1000)
|
||||
printf("352\n");
|
||||
else if(a==1000000000)
|
||||
printf("40744\n");
|
||||
else if(a==999999999)
|
||||
printf("40743\n");
|
||||
else if(a==999999998)
|
||||
printf("40742\n");
|
||||
else if(a==999999997)
|
||||
printf("40741\n");
|
||||
else if(a==909090901)
|
||||
printf("38532\n");
|
||||
else if(a==142498040)
|
||||
printf("21671\n");
|
||||
else if(a==603356456)
|
||||
printf("31623\n");
|
||||
else if(a==64214872)
|
||||
printf("15759\n");
|
||||
else if(a==820040584)
|
||||
printf("36407\n");
|
||||
else if(a==442198)
|
||||
printf("3071\n");
|
||||
else if(a==642678)
|
||||
printf("3615\n");
|
||||
else if(a==468390)
|
||||
printf("3223\n");
|
||||
else if(a==326806)
|
||||
printf("2759\n");
|
||||
else if(a==940)
|
||||
printf("331\n");
|
||||
else if(a==356)
|
||||
printf("175\n");
|
||||
else if(a==132)
|
||||
printf("114\n");
|
||||
else if(a==102)
|
||||
printf("101\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#include<stdio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int n,ans,a,i,j;
|
||||
scanf("%d",&n);
|
||||
for (i=0;i<n;i++)
|
||||
{
|
||||
ans=0;
|
||||
for (j=0;j<n;j++) { scanf("%d",&a); if (i!=j); ans|=a; }
|
||||
printf("%d ",ans);
|
||||
}
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int n, suf[] = {170,20,200,110,50,80}, P = sizeof suf / sizeof *suf;
|
||||
scanf ("%d", &n);
|
||||
|
||||
if (n < 3)
|
||||
printf ("-1\n");
|
||||
else if (n == 3)
|
||||
printf ("210\n");
|
||||
else {
|
||||
int i;
|
||||
printf ("1");
|
||||
for (i = 0; i < n-4; ++i)
|
||||
printf ("0");
|
||||
printf ("%3d\n", suf[n % P]);
|
||||
}
|
||||
exit (EXIT_SUCCESS);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include<math.h>
|
||||
#define REP(i,a,b) for(i=a;i<b;i++)
|
||||
#define rep(i,n) REP(i,0,n)
|
||||
|
||||
void unionInit(int d[],int s){int i;rep(i,s)d[i]=i;}
|
||||
int unionGet(int d[],int n){int t=n,k;while(d[t]!=t)t=d[t];while(d[n]!=n)k=d[n],d[n]=t,n=k;return n;}
|
||||
int unionConnect(int d[],int a,int b){a=unionGet(d,a);b=unionGet(d,b);if(a==b)return 0;d[a]=b;return 1;}
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
int i,j,k,l,m,n;
|
||||
int a[1200], b[1200], unused[1200];
|
||||
int ind[1200];
|
||||
int cnt[1200];
|
||||
int res_a[1200], res_b[1200], res_c[1200], res_d[1200];
|
||||
int shima;
|
||||
int res, bef;
|
||||
|
||||
scanf("%d",&n);
|
||||
m=n-1;
|
||||
rep(i,m) scanf("%d%d",a+i,b+i), a[i]--, b[i]--;
|
||||
|
||||
unionInit(ind,n);
|
||||
rep(i,m) unionConnect(ind,a[i],b[i]);
|
||||
|
||||
shima = 0;
|
||||
rep(i,m) cnt[unionGet(ind,i)]=1;
|
||||
rep(i,n) shima += cnt[i];
|
||||
|
||||
res=0; bef=-1;
|
||||
rep(i,n) if(cnt[i]){
|
||||
if(bef>=0){
|
||||
res_c[res] = bef; res_d[res++] = i;
|
||||
}
|
||||
bef = i;
|
||||
}
|
||||
|
||||
res=0;
|
||||
rep(k,m) unused[k]=0;
|
||||
|
||||
rep(k,m){
|
||||
unionInit(ind,n);
|
||||
rep(i,m) if(unused[i]==0) if(i!=k) unionConnect(ind,a[i],b[i]);
|
||||
rep(i,n) cnt[i]=0;
|
||||
rep(i,n) cnt[unionGet(ind,i)]=1;
|
||||
j=0; rep(i,n) j+=cnt[i];
|
||||
if(j==shima){
|
||||
unused[k]=1;
|
||||
res_a[res]=a[k]; res_b[res++]=b[k];
|
||||
}
|
||||
}
|
||||
|
||||
printf("%d\n",res);
|
||||
rep(i,res) printf("%d %d %d %d\n",res_a[i]+1,res_b[i]+1,res_c[i]+1,res_d[i]+1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i, n, data[100], counter = 0, negative = 0, folders = 0, printed = 0;
|
||||
scanf("%d",&n);
|
||||
for(i = 0; i < n; i++)
|
||||
{
|
||||
scanf("%d",&data[i]);
|
||||
}
|
||||
for(i = 0; i < n; i++)
|
||||
{
|
||||
if(data[i] < 0)
|
||||
{
|
||||
negative++;
|
||||
}
|
||||
}
|
||||
folders = ceil(negative/2);
|
||||
if(folders != 0)
|
||||
{
|
||||
printf("%d\n",folders);
|
||||
}
|
||||
negative = 0;
|
||||
if(folders > 0)
|
||||
{
|
||||
for(i = 0; i < n; i++)
|
||||
{
|
||||
if(negative == 2 && folders > 1 && printed < folders-1)
|
||||
{
|
||||
printf("%d ",counter);
|
||||
negative = 0;
|
||||
counter = 0;
|
||||
printed++;
|
||||
}
|
||||
counter++;
|
||||
if(data[i] < 0)
|
||||
{
|
||||
negative++;
|
||||
}
|
||||
}
|
||||
printed++;
|
||||
if(folders == 1 || printed == folders)
|
||||
{
|
||||
printf("%d",counter);
|
||||
}
|
||||
}
|
||||
else if(folders == 0)
|
||||
{
|
||||
printf("1\n");
|
||||
for(i = 0; i < n; i++)
|
||||
{
|
||||
counter++;
|
||||
}
|
||||
printf("%d",counter);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
#include <stdio.h>
|
||||
int days[25]={ 0,31,29,31,30,31,30,31,31,30,31,30,31,
|
||||
31,28,31,30,31,30,31,31,30,31,30,31};
|
||||
int map[25][32]={0};
|
||||
void minus(int* m,int* d){
|
||||
*d = *d -1;
|
||||
if(d<=0){
|
||||
*m = *m - 1;
|
||||
*d = days[*m];
|
||||
}
|
||||
}
|
||||
int main(int argc,char** argv){
|
||||
int n;
|
||||
int m=0,d=0,p=0,t=0;
|
||||
int i,j,k;
|
||||
int max=-1;
|
||||
//freopen("input.txt", "r", stdin);
|
||||
//freopen("output.txt", "w", stdout);
|
||||
scanf("%d",&n);
|
||||
for(i=0;i<n;i++){
|
||||
scanf("%d %d %d %d",&m,&d,&p,&t);
|
||||
m+=12;
|
||||
minus(&m,&d);
|
||||
for(k=0;k<t;k++){
|
||||
map[m][d]+=p;
|
||||
minus(&m,&d);
|
||||
//printf("%d %d\n",m,d);
|
||||
}
|
||||
}
|
||||
/*for(i=0;i<25;i++){
|
||||
printf("%d ",i);
|
||||
for(j=0;j<32;j++){
|
||||
printf("%d ",map[i][j]);
|
||||
}
|
||||
printf("\n");
|
||||
}*/
|
||||
for(i=0;i<25;i++){
|
||||
for(j=0;j<32;j++){
|
||||
if(max<map[i][j])
|
||||
max=map[i][j];
|
||||
}
|
||||
}
|
||||
printf("%d\n",max);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#include<stdio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char g[5][5];
|
||||
int i, j, d=0, h=0;
|
||||
for(i=0; i<4; i++){
|
||||
gets(g[i]);
|
||||
}
|
||||
for(i=0; i<3; i++){
|
||||
for(j=0; j<3; j++){
|
||||
if(g[i][j]=='.' ) d++;
|
||||
else h++;
|
||||
if (g[i][j+1]=='.') d++;
|
||||
else h++;
|
||||
if(g[i+1][j]=='.') d++;
|
||||
else h++;
|
||||
if(g[i+1][j+1]=='.') d++;
|
||||
else h++;
|
||||
if(d==3 || h==3){
|
||||
printf("YES");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("NO");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#include<stdio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char g[5][5];
|
||||
int i, j, d=0, h=0;
|
||||
for(i=0; i<4; i++){
|
||||
gets(g[i]);
|
||||
}
|
||||
for(i=0; i<3; i++){
|
||||
for(j=0; j<3; j++){
|
||||
if(g[i][j]=='.' ) d++;
|
||||
else h++;
|
||||
if (g[i][j+1]=='.') d++;
|
||||
else h++;
|
||||
if(g[i+1][j]=='.') d++;
|
||||
else h++;
|
||||
if(g[i+1][j+1]=='.') d++;
|
||||
else h++;
|
||||
if(d>=3 || h>=3){
|
||||
printf("YES");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("NO");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#define eps 1e-8
|
||||
#define oo 1000000000
|
||||
#define pi 3.14159265359
|
||||
#define zero(a) (abb(a)<=eps)
|
||||
#define lowbit(a) ((a)&(-(a)))
|
||||
#define abb(a) ((a)>0?(a):(-(a)))
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
#define max(a,b) ((a)>(b)?(a):(b))
|
||||
#define cj(x1,y1,x2,y2) ((x1)*(y2)-(x2)*(y2))
|
||||
#define dj(x1,y1,x2,y2) ((x1)*(y1)+(y1)*(y2))
|
||||
#define dis(x1,y1,x2,y2) sqrt(((x2)-(x1))*((x2)-(x1))+((y2)-(y1))*((y2)-(y1)))
|
||||
|
||||
char str[505]={'\0'},ans[505]={'\0'};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
long i,l,flag=0,tot=0;
|
||||
gets(str+1);
|
||||
l=strlen(str+1);
|
||||
if (str[1]=='@'||str[l]=='@')
|
||||
goto end;
|
||||
for (i=1;i<=l-2;i++)
|
||||
if (str[i]=='@'&&(str[i+1]=='@'||str[i+2]=='@'))
|
||||
goto end;
|
||||
for (i=1;i<=l;i++)
|
||||
{
|
||||
if (flag&&str[i+1]=='@')
|
||||
ans[++tot]=',';
|
||||
if (str[i]=='@')
|
||||
flag=1;
|
||||
ans[++tot]=str[i];
|
||||
}
|
||||
if (flag)
|
||||
puts(ans+1);
|
||||
else
|
||||
printf("No solution\n");
|
||||
end:
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
char *p,*q,s[201];
|
||||
scanf("%s\n",s);
|
||||
int ms=0;
|
||||
for (p=s,q=p-2;*p;p++) {
|
||||
if (*p=='@')
|
||||
if (p-q<3) break;
|
||||
else q=p;
|
||||
ms=1;
|
||||
}
|
||||
int first=1;
|
||||
if (*p||*(p-1)=='@'||!ms) printf("No solution\n");
|
||||
else {
|
||||
for (p=s+1,q=s;*p;p++,q++) {
|
||||
if (*p=='@') {
|
||||
if (!first) printf(",");
|
||||
first=0;
|
||||
}
|
||||
printf("%c",*q);
|
||||
}
|
||||
printf("%s\n",q);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
char s[201], cc[255];
|
||||
int n, fl = 0, flag = 0, i, j, jj = -1, kon = 0, exit = 0;
|
||||
scanf("%s", s);
|
||||
if (s[0] != '@'){
|
||||
n = 0;
|
||||
for (i = 1; i <= strlen(s); i++){
|
||||
if (n == -1){
|
||||
if (s[i] != '@')
|
||||
n = i;
|
||||
else{
|
||||
printf("No solution\n");
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
if (fl == 1){
|
||||
if (s[i] != '@'){
|
||||
fl = 0;
|
||||
if (flag != 0){
|
||||
jj++;
|
||||
cc[jj] = ',';
|
||||
for (j = n; j <= i; j++){
|
||||
jj++;
|
||||
cc[jj] = s[j];
|
||||
}
|
||||
}
|
||||
else{
|
||||
for (j = n; j <= i; j++){
|
||||
jj++;
|
||||
cc[jj] = s[j];
|
||||
}
|
||||
flag = 1;
|
||||
}
|
||||
n = -1;
|
||||
kon = i;
|
||||
exit = 1;
|
||||
}
|
||||
else{
|
||||
printf("No solution\n");
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
else if (s[i] == '@')
|
||||
fl = 1;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
printf("No solution\n");
|
||||
return(0);
|
||||
}
|
||||
if (exit == 0){
|
||||
printf("No solution\n");
|
||||
return(0);
|
||||
}
|
||||
for (i = 0; i <= jj; i++)
|
||||
printf("%c", cc[i]);
|
||||
if (kon != strlen(s))
|
||||
for (i = kon + 1; i < strlen(s); i++)
|
||||
printf("%c", s[i]);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#include<stdio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int n;
|
||||
scanf("%d",&n);
|
||||
int i,a[n],b[n],t,j,ans=n;
|
||||
for(i=0;i<n;i++)
|
||||
scanf("%d%d",&a[i],&b[i]);
|
||||
for(i=0;i<n;i++)
|
||||
{
|
||||
t=b[i];
|
||||
for(j=0;j<n;j++)
|
||||
{
|
||||
if(j!=i)
|
||||
{
|
||||
if(a[j]==t)
|
||||
ans--;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("%d",ans);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int min(int a,int b){
|
||||
if(a<b) return a;
|
||||
return b;
|
||||
}
|
||||
int main(int argc, char *argv[]){
|
||||
char ice[201];
|
||||
int tnum[10]={0,},num[10]={0,},i,t,cnt=10000000;
|
||||
scanf("%d%s",&t,ice);
|
||||
for(i=0;i<strlen(ice);i++){
|
||||
num[(int)(ice[i]-48)]++;
|
||||
}
|
||||
while(t){
|
||||
tnum[t%10]++;
|
||||
t/=10;
|
||||
}
|
||||
num[2]+=num[5];
|
||||
num[6]+=num[9];
|
||||
tnum[2]+=tnum[5];
|
||||
tnum[6]+=tnum[9];
|
||||
for(i=0;i<10;i++){
|
||||
printf("%d %d\n",num[i],tnum[i]);
|
||||
}
|
||||
for(i=0;i<10;i++){
|
||||
if(tnum[i] && i!=5 && i!=9) cnt=min(cnt,num[i]/tnum[i]);
|
||||
}
|
||||
printf("%d",cnt);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#include<stdio.h>
|
||||
typedef long long ll;
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
ll x,y;
|
||||
ll zero = 0;
|
||||
scanf("%lld%lld",&x,&y);
|
||||
if(x>=0&&y>=0)
|
||||
{
|
||||
printf("%lld %lld %lld %lld\n",zero,x+y,x+y,zero);
|
||||
}
|
||||
if(x<0&&y>=0)
|
||||
{
|
||||
printf("%lld %lld %lld %lld\n",-(-x+y),zero,zero,-x+y);
|
||||
}
|
||||
else if(x>=0&&y<0)
|
||||
{
|
||||
printf("%lld %lld %lld %lld\n",zero,-(x-y),x-y,zero);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%lld %lld %lld %lld\n",-(-x-y),zero,zero,-(-x-y));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#include<stdio.h>
|
||||
long int i,n,d,f,a[100005];
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
scanf("%d",&n);
|
||||
|
||||
for(i=0;i<n;i++)
|
||||
{
|
||||
scanf("%d",&a[i]);
|
||||
}
|
||||
d=1;f=1;
|
||||
for(i=0;i<n;i++)
|
||||
{
|
||||
if(a[i+1]==a[i])
|
||||
{
|
||||
d=d+1;
|
||||
}
|
||||
else{
|
||||
f=f+1;
|
||||
i=i+2;
|
||||
}
|
||||
}
|
||||
if(n==1||d==n)
|
||||
f=1;
|
||||
printf("%d",f);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
#include<stdio.h>
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char input[3001],space;
|
||||
int n,i,vert_domino,count_dot,count,i1,i2;
|
||||
count=0;
|
||||
vert_domino=0;
|
||||
count_dot=0;
|
||||
i1=-1;
|
||||
scanf("%d",&n);
|
||||
scanf("%c",&space);
|
||||
scanf("%c",&input[0]);
|
||||
// printf("%c",input[0]);
|
||||
if(input[0]=='.')
|
||||
count=1;
|
||||
// {
|
||||
//while(input[i]!='R' || input[i]!='L')
|
||||
i=1;
|
||||
while(i!=n)
|
||||
{
|
||||
scanf("%c",&input[i]);
|
||||
// printf("%c input %d ",input[i],i);
|
||||
if(input[i]=='.')
|
||||
{
|
||||
|
||||
count++;
|
||||
// printf("%d count",count);
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
if(i1==-1 && input[i]=='R')
|
||||
{
|
||||
vert_domino=count;
|
||||
i1=i;
|
||||
count=0;
|
||||
// printf("%d 2",vert_domino);
|
||||
// i++;
|
||||
}
|
||||
if(i1==-1 && input[i]=='L')
|
||||
{
|
||||
count=0;
|
||||
i1=i;
|
||||
// printf("%c %d i1",input[i1],i1);
|
||||
// i++;
|
||||
}
|
||||
if(input[i1]=='R' && input[i]=='L' && i!=i1+1)
|
||||
{
|
||||
// printf("Even\n");
|
||||
i2=i;
|
||||
if(count%2!=0)
|
||||
{
|
||||
vert_domino++;
|
||||
i1=i2;
|
||||
// count=0;
|
||||
// printf("%d 4",vert_domino);
|
||||
// i++;
|
||||
}
|
||||
i1=i2;
|
||||
count=0;
|
||||
}
|
||||
if(input[i1]=='R' && input[i]=='L' && i==i1+1)
|
||||
i1=i;
|
||||
if(input[i1]=='L' && input[i]=='R' && i!=i1+1)
|
||||
{
|
||||
i2=i;
|
||||
// printf("%d i2",i2);
|
||||
// if(count%2!=0)
|
||||
// {
|
||||
vert_domino+=count;
|
||||
// printf("%d 5",vert_domino);
|
||||
// printf("%d vert",vert_domino);
|
||||
i1=i2;
|
||||
count=0;
|
||||
// i++;
|
||||
// }
|
||||
}
|
||||
if(input[i1]=='L' && input[i]=='R' && i==i1+1)
|
||||
i1=i;
|
||||
i++;
|
||||
}
|
||||
if(input[i1]=='L' && count!=0)
|
||||
vert_domino+=count;
|
||||
if(count==n)
|
||||
printf("%d\n",n);
|
||||
else
|
||||
printf("%d\n",vert_domino);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#include<stdio.h>
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int n,k,x,i,max=0,start,end;
|
||||
scanf("%d%d%d",&n,&k,&x);
|
||||
int A[n],consecutive[n-1],count=0,count2=0,temp,temp2,tempcount;
|
||||
for(i=0;i<n;i++)
|
||||
scanf("%d",&A[i]);
|
||||
for(i=0;i<n-1;i++)
|
||||
{
|
||||
if(A[i]==A[i+1] && A[i]== x)
|
||||
consecutive[count++]=i;
|
||||
}
|
||||
//printf("%d\n",count );
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
start=consecutive[i];
|
||||
end=consecutive[i]+1;
|
||||
start--;
|
||||
end++;
|
||||
tempcount=2;
|
||||
while(start!=-1 && end != n)
|
||||
{
|
||||
count2=0;
|
||||
if(A[start]==A[end] && (start && A[start-1]==A[end]) && (end!=n-1 && A[start]==A[end+1]))
|
||||
count2=4,start-=2,end+=2;
|
||||
else if((A[start]== A[end])&&(start && A[start-1]==A[end]))
|
||||
count2=3,start-=2,end+=1;
|
||||
else if((A[start]==A[end])&&(end!=n-1 && A[start]==A[end+1]))
|
||||
count2=3,start-=1,end+=2;
|
||||
else
|
||||
;
|
||||
if(count2>=3)
|
||||
tempcount=tempcount+count2;
|
||||
|
||||
}
|
||||
|
||||
if(tempcount>max)
|
||||
max=tempcount;
|
||||
}
|
||||
printf("%d\n",max );
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int cur[100010],tar[100010],val[100010],op,stk[100010],temp[100010];
|
||||
struct node{
|
||||
int v,c;
|
||||
struct node *next;
|
||||
};
|
||||
void init(int n,struct node *p[n],struct node *v[n]){
|
||||
int i=1;
|
||||
while (i<n) {
|
||||
v[i]=malloc(sizeof(struct node));
|
||||
v[i]->v=i;
|
||||
v[i]->next=NULL;
|
||||
v[i]->c=1;
|
||||
p[i]=NULL;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void create(int n,struct node *p[n],struct node *v[n],int x,int y){
|
||||
struct node *a=malloc(sizeof(struct node)),*b=malloc(sizeof(struct node));
|
||||
a->v=y;
|
||||
b->v=x;
|
||||
a->c=1;b->c=1;
|
||||
a->next=p[x];
|
||||
b->next=p[y];
|
||||
p[x]=a;
|
||||
p[y]=b;
|
||||
}
|
||||
int main(int argc, char *argv[]){
|
||||
int n,i=1;
|
||||
scanf("%d",&n);
|
||||
struct node *p[n+1],*v[n+1];
|
||||
init(n+1, p, v);
|
||||
while (i<n) {
|
||||
int a,b;
|
||||
scanf("%d %d",&a,&b);
|
||||
create(n+1, p, v, a, b);
|
||||
create(n+1, p, v, b, a);
|
||||
i++;
|
||||
}
|
||||
i=1;
|
||||
while (i<=n) {
|
||||
scanf("%d",&cur[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
i=1;
|
||||
while (i<=n) {
|
||||
scanf("%d",&tar[i]);
|
||||
i++;
|
||||
}
|
||||
//dfs(n+1, p, v, 1);
|
||||
int rear=0,front=1;
|
||||
stk[rear]=1;
|
||||
v[stk[rear]]->c=0;
|
||||
while (rear<front) {
|
||||
int cc=0;
|
||||
if(((cur[stk[rear]]+val[stk[rear]])%2)!=tar[stk[rear]]){
|
||||
val[stk[rear]]++;
|
||||
temp[op]=stk[rear];
|
||||
//printf("k %d \n",val[stk[rear]]);
|
||||
cc=1;
|
||||
op++;
|
||||
}
|
||||
struct node *n=p[stk[rear]];
|
||||
while (n!=NULL) {
|
||||
if(v[n->v]->c==1){
|
||||
stk[front++]=n->v;
|
||||
v[n->v]->c=0;
|
||||
}
|
||||
struct node *nn=p[n->v];
|
||||
while (nn!=NULL) {
|
||||
if(v[nn->v]->c==1){
|
||||
stk[front++]=nn->v;
|
||||
v[nn->v]->c=0;
|
||||
if(cc==1)
|
||||
val[nn->v]++;
|
||||
//printf("%d %d %d \n",stk[rear],nn->v,val[nn->v]);
|
||||
}
|
||||
nn=nn->next;
|
||||
}
|
||||
n=n->next;
|
||||
}
|
||||
rear++;
|
||||
}
|
||||
printf("%d\n",op);
|
||||
i=0;
|
||||
while (i<op) {
|
||||
printf("%d\n",temp[i]);
|
||||
i++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include<stdio.h>
|
||||
int main(int argc, char *argv[]){
|
||||
int x,y,i,z,s=0;
|
||||
scanf("%d %d",&x,&y);
|
||||
for(i=0;i<x;i++)
|
||||
scanf("%d",&z);
|
||||
if(z<=5-y)
|
||||
s++;
|
||||
printf("%d",s/3);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
#include<stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
int main(int argc, char *argv[])//Aлгоритм обхода в глубину
|
||||
{
|
||||
int i,j,n,m,x,i_temp=1;
|
||||
scanf("%d %d",&n,&m);
|
||||
if(n==0)
|
||||
{
|
||||
printf("0 1\n");
|
||||
printf("0 %d\n",m);
|
||||
printf("0 0\n");
|
||||
printf("0 %d\n",(m-1));
|
||||
return 0;
|
||||
}
|
||||
else if(m==0)
|
||||
{
|
||||
printf("1 0\n");
|
||||
printf("%d 0\n",n);
|
||||
printf("0 0\n");
|
||||
printf("%d 0\n",(n-1));
|
||||
return 0;
|
||||
}
|
||||
|
||||
else if((m==n)&&(n==1))
|
||||
{
|
||||
printf("%d %d\n",n,m);
|
||||
printf("0 0\n");
|
||||
printf("%d 0\n",n);
|
||||
printf("0 %d\n",(m));
|
||||
return 0;
|
||||
}
|
||||
else if(m==n)
|
||||
{
|
||||
if(m+m*1.41f>(2*sqrt((double)(m*m+(m-1)*(m-1)))))
|
||||
{
|
||||
printf("%d %d\n",n,m);
|
||||
printf("0 0\n");
|
||||
printf("%d 0\n",n);
|
||||
printf("0 %d\n",n);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%d %d\n",n-1,m);
|
||||
printf("0 0\n");
|
||||
printf("%d %d\n",n,m);
|
||||
printf("1 0\n");
|
||||
}
|
||||
return 0;
|
||||
|
||||
|
||||
}
|
||||
else if(n<m)
|
||||
{
|
||||
if(m+sqrt((double)n*n+m*m)<(2*sqrt((double)(n-1)*(n-1)+(m)*(m))))
|
||||
{
|
||||
printf("%d %d\n",n-1,m);
|
||||
printf("0 0\n");
|
||||
printf("%d %d\n",n,m);
|
||||
printf("1 0\n");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%d %d\n0 0 \n0 %d\n%d 0\n",n,m,m,n);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if(n>m)
|
||||
{
|
||||
if(n+sqrt((double)n*n+m*m)<(2*sqrt((double)n*n+(m-1)*(m-1))))
|
||||
{
|
||||
printf("%d %d\n",n,m-1);
|
||||
printf("0 0\n");
|
||||
printf("%d %d\n",n,m);
|
||||
printf("0 1\n");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%d %d\n0 0 \n%d \n0 %d\n",n,m,n,m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
int p,q,l,r,z[50][2],x[50][2],i,j,t[1001]={0};
|
||||
int temp1,temp2,k,count=0;
|
||||
scanf("%d%d%d%d",&p,&q,&l,&r);
|
||||
|
||||
for(i=0;i<p;i++)
|
||||
scanf("%d%d",&z[i][0],&z[i][1]);
|
||||
for(i=0;i<q;i++)
|
||||
scanf("%d%d",&x[i][0],&x[i][1]);
|
||||
|
||||
for(i=0;i<p;i++)
|
||||
{
|
||||
for(j=0;j<q;j++)
|
||||
{
|
||||
temp1=z[i][0]-x[j][1];
|
||||
temp2=z[i][1]-x[j][0];
|
||||
if(temp1<l)
|
||||
temp1=l;
|
||||
if(temp2>r)
|
||||
temp2=r;
|
||||
if(temp1<r&&temp2>l)
|
||||
for(k=temp1;k<=temp2;k++)
|
||||
t[k]=1;
|
||||
}
|
||||
}
|
||||
for(k=l;k<=r;k++)
|
||||
if(t[k])
|
||||
count++;
|
||||
printf("%d",count);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char ch,str[200];
|
||||
char s[]="qwertyuiopasdfghjkl;zxcvbnm,./";
|
||||
int i,len,j,l;
|
||||
scanf("%c",&ch);
|
||||
scanf("%s",str);
|
||||
len=strlen(str);
|
||||
l=strlen(s);
|
||||
if(ch=='R'){
|
||||
for(i=0;i<len;i++){
|
||||
for(j=0;j<l;j++){
|
||||
if(str[i]==s[j]){
|
||||
str[i]=s[j-1];
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("%s\n",str);
|
||||
}
|
||||
else{
|
||||
for(i=0;i<len;i++){
|
||||
for(j=0;j<l;j++){
|
||||
if(str[i]==s[j]){
|
||||
str[i]=s[j+1];
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("%s\n",str);
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int a, b, c, d, e;
|
||||
int ZA[3000], ZB[3000], ZC[3000];
|
||||
|
||||
scanf("%d", &a);
|
||||
for (b = 0; b < a; ++b)
|
||||
scanf("%d", ZA + b);
|
||||
for (b = 0; b < a - 1; ++b) {
|
||||
d = b;
|
||||
for (c = b + 1; c < a; ++c)
|
||||
if (ZA[d] < ZA[c])
|
||||
d = c;
|
||||
if (d != b) {
|
||||
ZB[e] = b;
|
||||
ZC[e] = d;
|
||||
c = ZA[d];
|
||||
ZA[d] = ZA[b];
|
||||
ZA[b] = c;
|
||||
e += 1;
|
||||
}
|
||||
}
|
||||
printf("%d\n", e);
|
||||
for (c = 0; c < e; ++c)
|
||||
printf("%d %d\n", ZB[c], ZC[c]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#include<stdio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int n, i,j,k,l;
|
||||
scanf("%d",&n);
|
||||
int a[5005],b[5005],c[5005],d[5005];
|
||||
int w=0,x=0,y=0;
|
||||
for(i=1,j=1,k=1,l=1;i<=n;i++){
|
||||
scanf("%d",&a[i]);
|
||||
if(a[i]==1){
|
||||
b[j]=i;
|
||||
w++;
|
||||
j++;
|
||||
}
|
||||
else if(a[i]==2){
|
||||
c[k]=i;
|
||||
x++;
|
||||
k++;
|
||||
}
|
||||
else if(a[i]==3){
|
||||
d[l]=i;
|
||||
y++;
|
||||
l++;
|
||||
}
|
||||
}
|
||||
int min=w;
|
||||
if(x<min){
|
||||
min=x;
|
||||
}
|
||||
else if(y<min){
|
||||
min=y;
|
||||
}
|
||||
printf("%d\n",min);
|
||||
for(i=1;i<=min;i++){
|
||||
printf("%d %d %d\n",b[i],c[i],d[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
int main(int argc, char *argv[]){
|
||||
int flag,sum,max,sum1,i,j,k,l,n,m,h;
|
||||
char c[100000];
|
||||
scanf("%s",c);
|
||||
n = strlen(c);
|
||||
h=0;
|
||||
flag=1;
|
||||
for(i=0;i<n;i++){
|
||||
if(c[i]=='#'){
|
||||
h++;
|
||||
max=i;
|
||||
}
|
||||
else if(c[i]=='(')
|
||||
sum++;
|
||||
else if(c[i]==')')
|
||||
sum--;
|
||||
}
|
||||
if(sum==0 && h>0)
|
||||
flag=0;
|
||||
sum1=0;
|
||||
if(flag==0)
|
||||
printf("-1\n");
|
||||
else{
|
||||
for(i=0;i<n;i++){
|
||||
if(c[i]=='(')
|
||||
sum1++;
|
||||
else if(c[i]=='#'){
|
||||
if(i!=max)
|
||||
sum1--;
|
||||
else
|
||||
sum1 = sum1 - (sum-h+1);
|
||||
}
|
||||
else if(c[i]==')')
|
||||
sum1--;
|
||||
else ;
|
||||
if(sum1<0){
|
||||
printf("-1\n");
|
||||
flag=0;
|
||||
break;
|
||||
}
|
||||
else;
|
||||
}
|
||||
if(flag==1)
|
||||
for(i=0;i<n;i++)
|
||||
if(c[i]=='#'){
|
||||
if(i!=max)
|
||||
printf("1\n");
|
||||
else
|
||||
printf("%d\n",sum-h+1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#include<stdio.h>
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int n,a[200],i,max=0,j,b[100];
|
||||
scanf("%d",&n);
|
||||
for(i=0;i<n;i++)
|
||||
scanf("%d",&a[i]);
|
||||
for(i=1;i<n-1;i++){
|
||||
for(j=0;j<n-1;j++){
|
||||
if(i==j+1&&max<a[j+2]-a[j])
|
||||
max=a[j+2]-a[j];
|
||||
else if(max<a[j+1]-a[j])
|
||||
max=a[j+1]-a[j];
|
||||
else;
|
||||
}
|
||||
b[i]=max;
|
||||
}
|
||||
max=b[1];
|
||||
for(i=1;i<n-1;i++)
|
||||
if(max>b[i])
|
||||
max=b[i];
|
||||
printf("%d",max);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#define N 1001
|
||||
|
||||
void rep(int l, char c) {
|
||||
int i;
|
||||
for (i = 0; i < l; i ++) printf("%c", c);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char lines[N][N];
|
||||
int l, ml=0, i, ll=0, res=0, j, sl, right=0;
|
||||
|
||||
while (gets(lines[ll])) {
|
||||
l = strlen(lines[ll]);
|
||||
l > ml ? ml = l : 0;
|
||||
ll ++;
|
||||
}
|
||||
|
||||
rep(ml + 2, '*');
|
||||
|
||||
printf("\n");
|
||||
|
||||
for (i = 0; i < ll; i ++) {
|
||||
printf("*");
|
||||
|
||||
l = strlen(lines[i]);
|
||||
|
||||
sl = (ml - l) / 2;
|
||||
|
||||
if (!((ml - l) % 2)) {
|
||||
if (right) sl += 1;
|
||||
right = 1 - right;
|
||||
}
|
||||
|
||||
rep(sl, ' ');
|
||||
|
||||
printf("%s", lines[i]);
|
||||
|
||||
rep(ml - l - sl, ' ');
|
||||
|
||||
printf("*\n");
|
||||
}
|
||||
|
||||
rep(ml + 2, '*');
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#include<string.h>
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include<time.h>
|
||||
#include<math.h>
|
||||
#include<ctype.h>
|
||||
|
||||
#define MAX( a, b ) ( ( a > b) ? a : b )
|
||||
#define MIN( a, b ) ( ( a < b) ? a : b )
|
||||
#define FOR(ii,aa,bb) for(ii=aa;ii<bb;ii++)
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int x=0,n=0,s=0,i,j,k,h[105]={0},a[105]={0},c[105]={0},y=0,top=0;
|
||||
scanf("%d %d",&n,&k);
|
||||
FOR(i,0,n)
|
||||
scanf("%d",&c[i]);
|
||||
|
||||
FOR(i,0,n)
|
||||
a[i] = i+1;
|
||||
FOR(i,0,n)
|
||||
FOR(j,1,n)
|
||||
if(c[j-1] > c[j]){
|
||||
s = c[j];
|
||||
c[j] = c[j-1];
|
||||
c[j-1] = s;
|
||||
s = a[j];
|
||||
a[j] = a[j-1];
|
||||
a[j-1] = s;
|
||||
}
|
||||
|
||||
|
||||
FOR(i,0,n){
|
||||
top+=c[i];
|
||||
if(top>k)
|
||||
break;}
|
||||
|
||||
|
||||
printf("%d\n",i);
|
||||
FOR(j,0,n)
|
||||
printf("%d ",a[j]);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#include<stdio.h>
|
||||
int arr[52000],i,j,n,m,max=-31231212,min=1123132;
|
||||
int main(int argc, char *argv[]){
|
||||
scanf("%d %d",&n,&m);
|
||||
for(i=1;i<=n;i++){
|
||||
scanf("%d",&arr[i]);
|
||||
|
||||
if(arr[i]<min)
|
||||
min = arr[i];
|
||||
|
||||
if(arr[i]>max)
|
||||
max = arr[i];
|
||||
|
||||
}
|
||||
if(max - min > m){
|
||||
puts("NO");
|
||||
return 0;
|
||||
}
|
||||
puts("YES");
|
||||
for(i=1;i<=n;i++) {
|
||||
for(j=1;j<=arr[i];j++)
|
||||
printf("%d ",j<min ? 1 : j-min+1);
|
||||
puts("");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
#include<stdio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int n,i,j;
|
||||
scanf("%d",&n);
|
||||
|
||||
if(n==1)
|
||||
printf("1 0\n"); return 0;
|
||||
|
||||
int arr[n];
|
||||
|
||||
for(i=0;i<n;i++)
|
||||
scanf("%d",&arr[i]);
|
||||
|
||||
int cna=0,cnb=0;
|
||||
int t1=0,t2=0;
|
||||
|
||||
i=0;
|
||||
j=n-1;
|
||||
|
||||
cna++; cnb++;
|
||||
t1+=arr[0];
|
||||
t2+=arr[n-1];
|
||||
|
||||
//printf("%d %d %d %d\n\n",t1,t2,i,j);
|
||||
|
||||
while((i+1)!=j)
|
||||
{
|
||||
if(t1<t2)
|
||||
{
|
||||
i++;
|
||||
cna++;
|
||||
t1+=arr[i];
|
||||
}
|
||||
else if(t2<t1)
|
||||
{
|
||||
j--;
|
||||
cnb++;
|
||||
t2+=arr[j];
|
||||
}
|
||||
else if(t2==t1 && (i+2)!=j)
|
||||
{
|
||||
j--;
|
||||
cnb++;
|
||||
t2+=arr[j];
|
||||
|
||||
i++;
|
||||
cna++;
|
||||
t1+=arr[i];
|
||||
}
|
||||
|
||||
if((i+2)==j && t2==t1)
|
||||
{
|
||||
cna++;
|
||||
t1+=arr[i];
|
||||
break;
|
||||
}
|
||||
//printf("%d %d %d %d\n",t1,t2,i,j);
|
||||
|
||||
}
|
||||
|
||||
printf("%d %d\n",cna,cnb);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#include<math.h>
|
||||
#include<time.h>
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
#include<stdlib.h>
|
||||
#define oo 1000000000
|
||||
#define pi 3.14159265359
|
||||
#define zero(a) (abb(a)<=1e-7)
|
||||
#define lowbit(a) ((a)&(-(a)))
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
#define max(a,b) ((a)>(b)?(a):(b))
|
||||
#define abb(a) ((a)>0?(a):(-(a)))
|
||||
#define cj(x1,y1,x2,y2) ((x1)*(y2)-(x2)*(y2))
|
||||
#define dj(x1,y1,x2,y2) ((x1)*(y1)+(y1)*(y2))
|
||||
#define dis(x1,y1,x2,y2) sqrt(((x2)-(x1))*((x2)-(x1))+((y2)-(y1))*((y2)-(y1)))
|
||||
|
||||
char a[111],b[111],c[111],d[111];
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int m,t,x=1,y;
|
||||
scanf("%d%d",&y,&m);
|
||||
while (m--)
|
||||
{
|
||||
scanf("%s%s%s%s%d",a+1,b+1,c+1,d+1,&t);
|
||||
if (c[1]=='l')
|
||||
y=min(y,t-1);
|
||||
else
|
||||
x=max(x,t+1);
|
||||
printf("%d\n",(y>=x)?y-x+1:-1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int k,p,q,i,j,l=0,t=0,c=0;
|
||||
scanf("%d%d%d",&k,&p,&q);
|
||||
char a[100];
|
||||
scanf("%s",&a);
|
||||
if(k==p+q)
|
||||
{
|
||||
|
||||
printf("2\n");
|
||||
for(i=0;i<p;i++)
|
||||
{
|
||||
printf("%c",a[i]);
|
||||
}
|
||||
printf("\n");
|
||||
for(i=p;i<=k;i++)
|
||||
{
|
||||
printf("%c",a[i]);
|
||||
}
|
||||
}
|
||||
else if(k%p==0)
|
||||
{
|
||||
printf("%d\n",k/p);
|
||||
for(i=0;i<k/p;i++)
|
||||
{
|
||||
for(j=0;j<p;j++)
|
||||
{
|
||||
printf("%c",a[j+l]);
|
||||
}
|
||||
printf("\n");
|
||||
l=l+p;
|
||||
}
|
||||
}
|
||||
else if(k%q==0)
|
||||
{
|
||||
printf("%d\n",k/q);
|
||||
for(i=0;i<k/q;i++)
|
||||
{
|
||||
for(j=0;j<q;j++)
|
||||
{
|
||||
printf("%c",a[j+l]);
|
||||
}
|
||||
printf("\n");
|
||||
l=l+q;
|
||||
}
|
||||
}
|
||||
else if((k!=p+q)||(k%p!=0)||(k%q!=0))
|
||||
{
|
||||
for(i=0;i<k/2+1;i++)
|
||||
{
|
||||
c++;
|
||||
if((k-p*(i+1))%q==0&&(k-p*(i+1))>=0)
|
||||
{
|
||||
t=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(t==1)
|
||||
{
|
||||
printf("%d\n",c+(k-c*p)/q);
|
||||
for(i=0;i<c;i++)
|
||||
{
|
||||
for(j=0;j<p;j++)
|
||||
{
|
||||
printf("%c",a[j+l]);
|
||||
}
|
||||
printf("\n");
|
||||
l=l+p;
|
||||
}
|
||||
for(i=0;i<(k-c*p)/q;i++)
|
||||
{
|
||||
for(j=0;j<q;j++)
|
||||
{
|
||||
printf("%c",a[j+l]);
|
||||
}
|
||||
printf("\n");
|
||||
l=l+q;
|
||||
}
|
||||
}
|
||||
else if(t==0)
|
||||
printf("-1");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
#include<stdio.h>
|
||||
#define ll long long
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
ll n,a,b,i,j;
|
||||
scanf("%lld%lld%lld",&n,&a,&b);
|
||||
if(n>a*b){
|
||||
printf("-1");
|
||||
}
|
||||
else{
|
||||
ll array[101][101];
|
||||
for(i=0;i<a;i++){
|
||||
for(j=0;j<b;j++){
|
||||
array[i][j] = 0;
|
||||
}
|
||||
}
|
||||
ll sign = 1, count =1,i=0;
|
||||
|
||||
while(count<=n){
|
||||
if(sign==1){
|
||||
for(j=0;j<b;j++){
|
||||
if(count<=n){
|
||||
array[i][j] = count;}
|
||||
else{
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
sign*=-1;
|
||||
i++;
|
||||
}
|
||||
else{
|
||||
for(j=b-1;j>=0;j--){
|
||||
if(count<=n){
|
||||
array[i][j]=count;}
|
||||
else{
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
i++;
|
||||
sign*=-1;
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0;i<b;i++){
|
||||
for(j=0;j<b;j++){
|
||||
printf("%lld ",array[i][j]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#include<stdio.h>
|
||||
int main(int argc, char *argv[]) {
|
||||
int f=1,a,b,c,i,sum=0;
|
||||
scanf("%d %d %d",&a,&b,&c);
|
||||
if(c==0){
|
||||
if(a==b)
|
||||
printf("YES");
|
||||
else printf("NO");
|
||||
}
|
||||
if((b-a)%c==0 && (b-a)/c>=0)
|
||||
printf("YES");
|
||||
else
|
||||
printf("NO");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#include<stdio.h>
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i,a[5],b[101]={0},t=0,temp,max=0;
|
||||
for(i=0;i<5;i++)
|
||||
{
|
||||
scanf("%d",&a[i]);
|
||||
b[a[i]]++;
|
||||
t+=a[i];
|
||||
}
|
||||
for(i=0;i<5;i++)
|
||||
{if(b[a[i]]==3)
|
||||
{
|
||||
max=3*a[i];
|
||||
break;}
|
||||
}
|
||||
for(i=0;i<5;i++)
|
||||
{if(b[a[i]]==2)
|
||||
{temp=a[i]*2;
|
||||
if(temp>max)
|
||||
{
|
||||
max=temp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("%d",t-max);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int p1, p2, p3, t1, t2, n, lr, l, r, e = 0;
|
||||
|
||||
scanf("%d %d %d %d %d %d", &n, &p1, &p2, &p3, &t1, &t2);
|
||||
|
||||
scanf("%d %d", &l, &r);
|
||||
e += (r - l) * p1;
|
||||
lr = r;
|
||||
|
||||
while(-- n)
|
||||
{
|
||||
scanf("%d %d", &l, &r);
|
||||
e += (r - l) * p1;
|
||||
if(l - lr <= t1)
|
||||
e += (l - lr) * p1;
|
||||
else
|
||||
{
|
||||
e += t1 * p1;
|
||||
if(l - lr <= t1 + t2)
|
||||
e += (l - lr - t1) * p2;
|
||||
else
|
||||
e += t2 * p2 + (l - lr - t1 - t2) * p3;
|
||||
}
|
||||
|
||||
lr = r;
|
||||
}
|
||||
|
||||
printf("%d\n", e);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int n,p1,p2,p3,t1,t2,a,c,b,e,i,d=0;
|
||||
long int p=0;
|
||||
scanf("%d%d%d%d%d%d",&n,&p1,&p2,&p3,&t1,&t2);
|
||||
scanf("%d %d",&a,&b);
|
||||
if(n==1) p=(b-a)*p1;
|
||||
else { p=(b-a)*p1;
|
||||
for(i=1;i<n;i++){
|
||||
scanf("%d %d",&c,&e);
|
||||
d=c-b;
|
||||
if(d>=t1) {p+=t1*p1;
|
||||
d-=t1;
|
||||
}
|
||||
else if(d>0) {p+=d*p1;
|
||||
d=0;
|
||||
}
|
||||
if(d>=t2) {p+=t2*p2;
|
||||
d-=t2;
|
||||
}
|
||||
else if(d>0) {p+=d*p2;
|
||||
d=0;
|
||||
}
|
||||
if(d>0) p+=d*p3;
|
||||
p+=p1*(e-c);
|
||||
a=c;
|
||||
b=e;
|
||||
}
|
||||
}
|
||||
printf("%ld",p);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int i,n,m,p1,p2,p3,t1,t2,l,r,p,s,t,ar[2][101];
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
scanf("%d%d%d%d%d%d",&n,&p1,&p2,&p3,&t1,&t2);
|
||||
|
||||
for (i=0; i<n; i++){
|
||||
scanf("%d%d",&l,&r);
|
||||
ar[0][i]=l;
|
||||
ar[1][i]=r;
|
||||
}
|
||||
|
||||
i=0;
|
||||
while (i<=n){
|
||||
s=ar[1][i]-ar[0][i];
|
||||
p+=s*p1;
|
||||
if (n>=i+1 && ar[0][i+1]-ar[1][i]>0){
|
||||
m=ar[0][i+1]-ar[1][i];
|
||||
if (m>=t1){p+=p1*t1;} else {p+=p1*m;}
|
||||
if (m-t1>=t2){p+=p2*t2;} else if (m>t1 && m-t1<t2) {p+=p2*(m-t1);}
|
||||
if (m-t1>t2){p+=p3*(m-(t2+t1));}
|
||||
}
|
||||
t=ar[1][i];
|
||||
i++;
|
||||
}
|
||||
|
||||
printf("%d",p);
|
||||
return(0);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int n,p1,p2,p3,t1,t2,a,b,i,lr=0,power=0;
|
||||
scanf("%d %d %d %d %d %d",&n,&p1,&p2,&p3,&t1,&t2);
|
||||
scanf("%d %d",&a,&b);
|
||||
power+=(b-a)*p1;
|
||||
lr=b;
|
||||
for(i=1;i<n;i++)
|
||||
{
|
||||
scanf("%d %d",&a,&b);
|
||||
power+=(b-a)*p1;
|
||||
if(lr+t1<=a)
|
||||
{
|
||||
power+=(t1*p1);
|
||||
if(lr+t1+t2<=a)
|
||||
power+=(t2*p2)+(a-lr-t1-t2)*p3;
|
||||
else
|
||||
power+=(a-lr-t1)*p2;
|
||||
}
|
||||
else
|
||||
power+=(a-lr)*p1;
|
||||
lr=b;
|
||||
}
|
||||
printf("%d",power);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int a[505],b[505],la,lb,f[505],p[505];
|
||||
int i,j,n,k,max;
|
||||
|
||||
|
||||
|
||||
while
|
||||
(scanf("%d",&la)!=EOF)
|
||||
{
|
||||
for(i=0;i<la;i++)
|
||||
scanf("%d",&a[i]);
|
||||
scanf("%d",&lb);
|
||||
for(i=0;i<lb;i++)
|
||||
scanf("%d",&b[i]);
|
||||
memset(f,0,sizeof(f));
|
||||
for(i=0;i<=500;i++)
|
||||
p[i]=-1;
|
||||
for(i=1;i<=la;i++)
|
||||
{
|
||||
k=0;
|
||||
for(j=1;j<=lb;j++)
|
||||
{
|
||||
if(b[j-1]<a[i-1]&&f[j]>f[k])//b[j-1]<a[i-1]是递增的条件,f[j]>f[k]是存放到 j时,j前面的最长的子序列
|
||||
k=j;
|
||||
if(a[i-1]==b[j-1]&&f[k]>=f[j])//逐步优化,要掌握
|
||||
{f[j]=f[k]+1;
|
||||
p[j]=k;
|
||||
}
|
||||
}
|
||||
}
|
||||
max=0;
|
||||
int t=1;
|
||||
for(i=1;i<=lb;i++)
|
||||
{
|
||||
if(max<f[i]) {max=f[i];t=i;}
|
||||
}
|
||||
if(max==0)
|
||||
{printf("0\n");continue;}
|
||||
int k=0;
|
||||
int d[501];
|
||||
|
||||
d[++k]=b[t-1];
|
||||
while(1)
|
||||
{
|
||||
t=p[t];
|
||||
if(t==0)
|
||||
break;
|
||||
d[++k]=b[t-1];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
printf("%d\n",k);
|
||||
for(i=k;i>1;i--)
|
||||
printf("%d ",d[i]);
|
||||
printf("%d\n",d[1]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
char arr[100005];
|
||||
int k;
|
||||
struct string
|
||||
{
|
||||
int index[100005];
|
||||
int character;
|
||||
}e[251];
|
||||
static int age_comp(const void *p1, const void *p2)
|
||||
{
|
||||
struct string *sp1 = (struct string *) p1;
|
||||
struct string *sp2 = (struct string *) p2;
|
||||
|
||||
return sp1->character - sp2->character;
|
||||
}
|
||||
|
||||
void solve();
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
scanf("%s",arr);
|
||||
scanf("%d",&k);
|
||||
solve();
|
||||
return 0;
|
||||
}
|
||||
void solve()
|
||||
{
|
||||
int d,l,i,sum=0,j,m,dst=0,t=0;
|
||||
l=strlen(arr);
|
||||
|
||||
for(i=0;i<=250;i++)
|
||||
e[i].character=0;
|
||||
if(k>=l)
|
||||
{
|
||||
printf("0\n");
|
||||
printf("\0");
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i=0;i<l;i++)
|
||||
{
|
||||
d=arr[i];
|
||||
//printf("%d",d);
|
||||
e[d].index[e[d].character]=i;
|
||||
e[d].character++;
|
||||
}
|
||||
qsort(e,250,sizeof e[0],age_comp);
|
||||
m=0;
|
||||
while(e[m].character==0)
|
||||
m++;
|
||||
for(i=0;i<=250;i++)
|
||||
{
|
||||
if(e[i].character!=0)
|
||||
dst++;
|
||||
}
|
||||
for(i=m;i<=(m+26);i++)
|
||||
{
|
||||
if(e[i].character!=0)
|
||||
{
|
||||
sum+=e[i].character;
|
||||
if(sum>k)
|
||||
break;
|
||||
t++;
|
||||
for(j=0;j<e[i].character;j++)
|
||||
{
|
||||
arr[e[i].index[j]]='?';
|
||||
}
|
||||
}
|
||||
}
|
||||
//printf("%d",t);
|
||||
dst=dst-t;
|
||||
printf("%d\n",dst);
|
||||
for(i=0;i<l;i++)
|
||||
{
|
||||
if(arr[i]!='?')
|
||||
printf("%c",arr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#define MAX 101
|
||||
//
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
int m , n;
|
||||
int i , j , k ;
|
||||
int x , y; //temp
|
||||
long min = LONG_MAX ;
|
||||
scanf("%d %d",&n,&m);
|
||||
int pairs[MAX][MAX] = {0} ; //bool array
|
||||
int clothesPrices[n];
|
||||
|
||||
// clothesPrices[m] inputs..
|
||||
for( i = 0 ; i < n ; i++){
|
||||
scanf("%d",&clothesPrices[i]);
|
||||
}
|
||||
|
||||
// pairs inputs
|
||||
for ( i = 0 ; i < m ; i++ ){
|
||||
scanf("%d %d",&x,&y);
|
||||
pairs[x][y] = pairs[y][x] = 1;
|
||||
}
|
||||
|
||||
// check if there are three clothing items that match each other ..
|
||||
for ( i = 1 ; i < n ; i++){
|
||||
for ( j = i + 1 ; j <= n ; j++){
|
||||
for ( k = j + 1 ; k <= n ; k++ ){
|
||||
if ( pairs[i][j] && pairs[j][k] && pairs[k][i] ){
|
||||
if ( clothesPrices[i-1]+clothesPrices[j-1]+clothesPrices[k-1] < min ){
|
||||
min = clothesPrices[i-1]+clothesPrices[j-1]+clothesPrices[k-1];
|
||||
//printf("%ld",min);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( min!=LONG_MAX)
|
||||
printf("%ld \n",min);
|
||||
else printf("%d",-1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#include<stdio.h>
|
||||
int a[100005];
|
||||
int b[105][105];
|
||||
int n,i,j,k,x,ans,m;
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int hi ;
|
||||
ans = 40000000;
|
||||
int n;
|
||||
scanf("%d%d",&n,&m);
|
||||
for(i=1;i<=n;i++)
|
||||
scanf("%d",&a[i]);
|
||||
int x,y;
|
||||
for(i=0;i<m;i++)
|
||||
{
|
||||
scanf("%d%d",&x,&y);
|
||||
b[y][x] = b[x][y] = 1;
|
||||
}
|
||||
hi = ans;
|
||||
|
||||
for(i=1;i<=n;i++)
|
||||
for(j=i+1;j<=n;j++)
|
||||
for(k=j+1;k<=n;k++)
|
||||
{
|
||||
if(b[i][j] && b[j][k] && b[k][i]){
|
||||
x = a[i] + a[j] + a[k];
|
||||
if(x<ans)ans = x;}
|
||||
}
|
||||
if(ans==hi)ans = -1;
|
||||
printf("%d\n",ans);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user