Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
e57d9ab
Add files via upload
javaarchive Jun 15, 2018
b20e7d6
Add files via upload
javaarchive Jun 24, 2018
d1ed7a1
Add files via upload
javaarchive Jun 24, 2018
69f3073
Add files via upload
javaarchive Jun 24, 2018
ba52039
Add files via upload
javaarchive Jun 24, 2018
c9846bc
Add files via upload
javaarchive Jun 24, 2018
4164694
Update README.md
javaarchive Jun 24, 2018
71945b1
Add files via upload
javaarchive Jul 9, 2018
88d6f53
Add files via upload
javaarchive Jul 22, 2018
0e90eaf
Add files via upload
javaarchive Sep 10, 2018
85a40a2
Kind of Merge branch 'master' into usacocode
javaarchive Sep 10, 2018
2fdbb90
Merge branch 'usacocode' of https://github.com/javaarchive/Java into …
javaarchive Sep 10, 2018
3f3b2e3
Add files via upload
javaarchive Sep 10, 2018
c4e97ca
Update README.md
javaarchive Sep 10, 2018
593ed06
Casework complete!!!!
javaarchive Sep 10, 2018
a7477d7
Add files via upload
javaarchive Oct 1, 2018
24b02c3
Add files via upload
javaarchive Oct 20, 2018
c0c7d18
Copy eclipse project
javaarchive Nov 5, 2018
c165941
Something...
javaarchive Dec 29, 2018
6161330
Some new stuff
javaarchive Jan 15, 2019
088e7ea
Added my other ignore file
javaarchive Jan 15, 2019
16d4991
Reverted to old loop stopping code
javaarchive Jan 15, 2019
8057f57
Removed my test line
javaarchive Jan 15, 2019
2d0cdd3
Large test case output version
javaarchive Jan 15, 2019
7c5a3a2
test case test for case 2 is off
javaarchive Jan 15, 2019
3db5a7c
Testing new calculations
javaarchive Jan 15, 2019
f095e67
New calculation failed
javaarchive Jan 15, 2019
464bfcb
Delete some code...............
javaarchive Jan 15, 2019
5065dbb
Quick edit
javaarchive Jan 15, 2019
bb99832
Added line empty or not logic
javaarchive Jan 15, 2019
430b23d
sort by senority
javaarchive Jan 15, 2019
b8ccaf0
Senority sort
javaarchive Jan 15, 2019
7d601ba
more code...
javaarchive Jan 15, 2019
1dfd4b4
Added more
javaarchive Jan 15, 2019
8e21161
Almost working code
javaarchive Jan 15, 2019
1b934a2
Started debugging
javaarchive Jan 15, 2019
36d0480
Rewrite
javaarchive Jan 15, 2019
7faac51
A WORKING VERSION
javaarchive Jan 15, 2019
a7198ed
Merge branch 'usacocode' of https://github.com/javaarchive/Java into …
javaarchive Jan 15, 2019
63df8b3
Add files via upload
javaarchive Apr 29, 2019
aae93bf
Add files via upload
javaarchive Apr 29, 2019
014816e
Add files via upload
javaarchive Apr 29, 2019
d0eef15
Add files via upload
javaarchive Jun 21, 2019
ac1d366
Add files via upload
javaarchive Jun 22, 2019
a88e159
Add Unmodified version from yesterday
javaarchive Jun 28, 2019
da5933e
Add files via upload
javaarchive Jun 28, 2019
164c572
Add files via upload
javaarchive Jun 28, 2019
ff21b5c
Upload NonWorking edition
javaarchive Jun 28, 2019
251210d
ReOptimize
javaarchive Jun 28, 2019
eb40298
Intersection method change
javaarchive Jun 28, 2019
a133fdd
Add files via upload
javaarchive Jun 28, 2019
95649e4
Fixing some things up
javaarchive Jun 28, 2019
2cdd677
Longing for longs
javaarchive Jun 28, 2019
05bf005
U-S-A-C-O
javaarchive Jun 28, 2019
a876b51
new code
javaarchive Jun 28, 2019
9ce8286
Add files via upload
javaarchive Jun 28, 2019
860e9e3
Working Solution
javaarchive Jun 29, 2019
24311f3
Update README.md
javaarchive Jan 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Java
<<<<<<< HEAD
DON'T use download
USE RELEASES
Some files belong to usaco and I do not own them. Also this is my code. Do not use without permission on usaco website!!!!!!!!!!
Expand All @@ -8,4 +7,3 @@ Useful library for usaco and other purposes.
. Use releases when possible otherwise download usacotools.java.
# Release dates and more
Find release dates at https://javaarchive.github.io/Java/. Moved to https://github.com/javaarchive/Java/wiki
>>>>>>> master
19 changes: 19 additions & 0 deletions barn1.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
4 50 18
3
4
6
8
14
15
16
17
21
25
26
27
30
31
40
41
42
43
17 changes: 9 additions & 8 deletions barn1.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public static void main(String[] args) throws IOException{
blockedstall=Integer.parseInt(f.readLine());
stalls[blockedstall]=1;
bstalls[i]=blockedstall;

}
f.close();
f=null;
Expand All @@ -55,21 +54,23 @@ public static void main(String[] args) throws IOException{

for(int bs1:bstalls) {
for(int bs2:bstalls) {
if(bs1==bs2) {
System.out.println("Debug point 2: Info, blockedstall: "+blockedstall+", combination: "+combination+", More info: bs1: "+bs1+", bs2: "+bs2);
if(bs1==bs2 || bs1>bs2 || bs1==0 || bs2==0) {
//System.out.println("Debug point 2: Info, blockedstall: "+blockedstall+", combination: "+combination+", More info: bs1: "+bs1+", bs2: "+bs2);
System.out.println("Both are same, bs1: "+bs1+", bs2: "+bs2);
continue;
}else {
combination++;//increment
blockedstall=boarddist(bs1,bs2);
System.out.println("Debug point 1: Info, blockedstall: "+blockedstall+", combination: "+combination+", More info: bs1: "+bs1+", bs2: "+bs2);
//System.out.println("Debug point 1: Info, blockedstall: "+blockedstall+", combination: "+combination+", More info: bs1: "+bs1+", bs2: "+bs2);
System.out.println("bs1: "+bs1+", bs2: "+bs2);
mergecosts[blockedstall][combination][0]=bs1;
mergecosts[blockedstall][combination][1]=bs2;

}
}
}
System.out.println(combination);
combination=0;
//for(int i=0;i<)

//for(int i=0;i<)
}

}
}
61 changes: 22 additions & 39 deletions citystate.java
Original file line number Diff line number Diff line change
@@ -1,59 +1,42 @@
import java.io.*;
import java.util.*;

public class citystate {
public static double decify(int num) {
return 0.01*num;
}
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
BufferedReader f=new BufferedReader(new FileReader("citystate.in"));
public static void main(String[] args) throws IOException{
PrintWriter pw=new PrintWriter(new BufferedWriter(new FileWriter("citystate.out")));
double c1,c2;
BufferedReader f=new BufferedReader(new FileReader("2.in"));
int answer=0;
int N=Integer.parseInt(f.readLine());
String[] state=new String[N];//INIT storage for state
String[] city=new String[N];//INIT storage for city
ArrayList<String> hitstates=new ArrayList<String>();
ArrayList<String> hitcities=new ArrayList<String>();
List<String> k=new ArrayList<String>();
List<String> checkstate=new ArrayList<String>();
StringTokenizer st;
for(int i=0;i<N;i++) {
st=new StringTokenizer(f.readLine());
state[i]=st.nextToken();
city[i]=st.nextToken();
//System.out.println("READ");
checkstate.add(st.nextToken());
k.add(st.nextToken());

}
int a,b,c,d,e;
e=0;
String state,city;
for(int i=0;i<N;i++) {
a=((int) city[i].charAt(0)) -(int) ' ';
b=((int) city[i].charAt(1))-(int) ' ';
c1=(((double)a)+(decify(b)));
for(int j=i+1;j<N;j++) {
if(j==i) {
state=checkstate.get(0);
city=k.get(0);
for(int j=0;j<k.size();j++) {
if(i==j) {
continue;
}
c=((int) state[j].charAt(0))-(int) ' ';
d=((int) state[j].charAt(1))-(int) ' ';
c2=(((double)c)+decify(d));

//System.out.println("Debug "+c1+" , "+c2+" "+state[j].charAt(0)+state[j].charAt(1)+" "+city[i].charAt(0)+city[i].charAt(1));
if(c2==c1) {

//System.out.println("HIT");
//System.out.println(city[i]+" "+state[j]+" "+city[j]+" "+state[i]);
if(city[j].equals(state[i].substring(0, 2))){
e++;
}
if(k.get(j).equals(state.substring(0,2))&&!(checkstate.get(j).equals(state))) {
answer++;
System.out.println(k.get(j)+" is equal to "+state);
}
}
k.remove(0);
checkstate.remove(0);
//System.out.println(city+" "+state);

}
//String a1,a2;


pw.println(e);
pw.println(answer);
pw.close();
f.close();
}


}
52 changes: 52 additions & 0 deletions cowsignal.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import java.io.*;
import java.util.*;
public class cowsignal {
private static int K;
public static ArrayList<ArrayList<Character>> build(ArrayList<ArrayList<Character>> map,int y,char l){
for(int i=y*K;i<((y+1)*K);i++) {
for(int j=0;j<K;j++) {
map.get(i)
.add(l);
};
}
return map;
}
//private static final char s_OFF = 'B';
//private static final char s_ON = '.';
public static void main(String[] args) throws IOException{
BufferedReader f=new BufferedReader(new FileReader("cowsignal.in"));
StringTokenizer st=new StringTokenizer(f.readLine());
int M=Integer.parseInt(st.nextToken());
int N=Integer.parseInt(st.nextToken());
K=Integer.parseInt(st.nextToken());
String temp;
ArrayList<ArrayList<Character>> omap=new ArrayList<ArrayList<Character>>();
for(int i=0;i<(M*K);i++){

omap.add(new ArrayList<Character>());
}
System.out.println("M*K "+M*K);
//Character[][] map=new Character[M][N];
for(int i=0;i<M;i++) {
temp=f.readLine();
for(int j=0;j<N;j++) {
//map[i][j]=temp.charAt(j);
omap=build(omap,i,temp.charAt(j));
}
}
f.close();
PrintWriter out=new PrintWriter(new FileWriter("cowsignal.out"));
for(int i=0;i<(M*K);i++) {
for(int j=0;j<(N*K);j++) {
out.print(omap.get(i).get(j));
}
out.println();
}
out.flush();
out.close();



}

}
188 changes: 188 additions & 0 deletions cowtiper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
import java.io.*;
//import java.util.*;
import modules.PrettyPrinter;
public class cowtiper {
private static int[][] field;
private static int N;
private static boolean patch;
public static int c(char bit) {
switch(bit) {
case '1':
patch=false;
return 1;
case '0':
return 0;
default:
return -1;
}
}
public static int sum(int[][] a) {
/*
* Finds total amount of cows not tipped over
*/
int out=0;
for(int i=0;i<N;i++) {
for(int j=0;j<N;j++) {
if(a[i][j]==0) {
out++;
}
}
}
return out;
}
public static int[][] invert(int[][] a){
for(int i=0;i<N;i++) {
for(int j=0;j<N;j++) {

if(a[i][j]==1) {
a[i][j]=0;
}else if(a[i][j]==0) {
a[i][j]=1;
}

}
}
return a;
}
public static int[][] invert(int[][] a,int x,int y){
for(int i=0;i<x;i++) {
for(int j=0;j<y;j++) {
System.out.println("Invert X:"+i+" Y:"+j+"");

if(a[i][j]==1) {
a[i][j]=0;
}else if(a[i][j]==0) {
a[i][j]=1;
}

}
}
return a;
}
public static int[][] best(int[][] a){
int temp=sum(a);
if(temp<((N*N)-temp)) {
a=invert(a);
}
return a;
}
public static int[][] best_NS(int[][] a){
int temp=sum(a);
if(temp<((N*N)-temp)) {
a=invert(a);
}
return a;
}
public static int[][] best(int[][] a,int x,int y){
int temp=sum(a);
if(temp<((N*N)-temp)) {
a=invert(a,x,y);
}
return a;
}
public static int[][] best_NS(int[][] a,int x,int y){
int temp=sum(a);
if(temp<((N*N)-temp)) {
a=invert(a,x,y);
}
return a;
}
public static void showfield() {
String[][] ppa=new String[N][N];
//field=best(field);
PrettyPrinter pp=new PrettyPrinter(System.out);
for(int i = 0; i < N; i++)
{
for(int j = 0; j < N; j++)
ppa[i][j] = Integer.toString(field[i][j]);
}
pp.print(ppa);
}

public static int hx(int[][] a) {
int l=0;
for(int i=0;i<N;i++) {
for(int j=0;j<N;j++) {
if(a[i][j]==1) {
if(i>l) {
l=i;
}
}
}
}
return l;
}
public static int hy(int[][] a) {
int l=-1;
for(int i=0;i<N;i++) {
for(int j=0;j<N;j++) {
if(a[i][j]==1) {
if(j>l) {
l=j;
}
}
}
}
return l;
}
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
BufferedReader f=new BufferedReader(new FileReader("5(1).in"));
N = Integer.parseInt(f.readLine());
field = new int[N][N];

String temp;
patch = true;
for(int i=0;i<N;i++) {
temp=f.readLine();
for(int j=0;j<N;j++) {
field[i][j]=c(temp.charAt(j));
//Integer.parseInt(Character.toString(temp.charAt(j)));
}
}
f.close();
//Begin debug zone
showfield();
String[][] ppa=new String[N][N];

field=best(field); // DO NOT REMOVE

PrettyPrinter pp=new PrettyPrinter(System.out);
for(int i = 0; i < N; i++)
{
for(int j = 0; j < N; j++)
ppa[i][j] = Integer.toString(field[i][j]);
}
pp.print(ppa);

//End debug zone
int test=0;
//if(sum(field)==(N*N)) {
test=0;
//}else {
test=1;

while(sum(field)!=(N*N)) {
//if()
showfield();
System.out.println(hx(field));
System.out.println(hy(field));
field=invert(field,hx(field)+1,hy(field)+1);
showfield();//Debug
//Thread.sleep(500);
test++;
if(test>10000) {
throw new Exception("Auto terminate");
}
}
//}

PrintWriter pw=new PrintWriter(new BufferedWriter(new FileWriter("cowtip.out")));
if(patch) {test=0;}
pw.println(test);
pw.flush();
pw.close();

}

}
Loading