Created
March 1, 2015 18:55
-
-
Save kik/ba7f3ba6699932539913 to your computer and use it in GitHub Desktop.
TLE 2015
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <set> | |
#include <string> | |
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
int T; | |
cin >> T; | |
char buf[2048]; | |
cin.getline(buf, 2048); | |
for (int i = 0; i < T; i++) { | |
cin.getline(buf, 2048); | |
string s = buf; | |
//cin >> s; | |
set<string> x; | |
for (size_t j = 0; j < s.size(); j++) { | |
for (size_t k = j + 1; k <= s.size(); k++) { | |
x.insert(s.substr(j, k - j)); | |
} | |
} | |
cout << x.size() << endl; | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int P(int a, int b) | |
{ | |
return a?P((a&b)<<1,a^b):b; | |
} | |
int main() | |
{ | |
int T,c,r; | |
for (scanf("\45d ", &T);T;T=P(T, ~0)) { | |
r = 0; | |
for (; (c = getchar())>10;) | |
r = P(P(r<<3, r<<1), P(c, ~47)); | |
scanf("\45\52s\45d ", &c); | |
r |= 1<<c; | |
printf("\45d\n", r & P(1,~r)); | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
asm("r:mov %ecx,%eax;syscall;ret");int b[9];_start(){r(0,r(1,b,r(0,b,917,0),1),0,60);} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = $<.to_a.join('').gsub("\n", '') | |
print "#include <stdio.h>\n" | |
print "char d[] = \"" | |
i = 0 | |
while i < 300 * 800 | |
ch = x[i] | |
c = 0 | |
while x[i] == ch | |
i += 1 | |
c += 1 | |
end | |
while c > 255 | |
#print "255,0," | |
printf "%c%c", 255, 0 | |
c -= 255 | |
end | |
#print "#{c}," | |
if c == 10 | |
print '\n' | |
elsif c == 13 | |
print '\r' | |
elsif c == 34 | |
print '\"' | |
elsif c == 92 | |
print '\\\\' | |
else | |
if true #c != 15 | |
printf "%c", c | |
else | |
printf "\\x%x", c | |
printf '" | |
"' | |
end | |
end | |
end | |
print "\";" | |
s = <<'E' | |
int c,j; | |
main() | |
{ | |
for(;j<240000;j++){ | |
while(!d[c]--)c++; | |
putchar(c&1?35:46); | |
if(-~j%800==0)puts(""); | |
} | |
return 0; | |
} | |
E | |
print s.gsub(/^ */, '').gsub("\n", '') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <cstdio> | |
#include <algorithm> | |
using namespace std; | |
int count(const string& s, const string& k) | |
{ | |
size_t p = 0, q; | |
int n = 0; | |
while ((q = s.find(k, p)) != string::npos) { | |
p = q+1; | |
n++; | |
} | |
return n; | |
} | |
void fail() | |
{ | |
abort(); | |
} | |
int cx = 0; | |
void counter(int n) | |
{ | |
if (cx == n) fail(); | |
cx++; | |
} | |
int main() | |
{ | |
string p; | |
char buf[999]; | |
while (fgets(buf, 999, stdin)) { | |
p += buf; | |
if (buf[0] == '}') { | |
{ | |
int score = 0; | |
int wh = count(p, "while"); | |
int fr = count(p, "for"); | |
int iff = count(p, "if"); | |
int gt = count(p, "goto"); | |
int br = count(p, "break"); | |
int ct = count(p, "continue"); | |
int rt = count(p, "return"); | |
if (gt > 0) fail(); | |
if (rt != 1) fail(); | |
if (iff > 2) fail(); | |
if (wh > 3) fail(); | |
if (fr > 1) fail(); | |
if (br > 1) fail(); | |
if (ct > 1) fail(); | |
if (fr && wh == 2) fail(); | |
//if (fr && wh == 1) fail(); | |
//if (fr && wh == 0) fail(); | |
if (fr + wh == 0) { | |
score += 10000; | |
} else if (fr + wh == 2) { | |
if (iff) { | |
if (br) fail(); | |
if (ct) fail(); | |
//counter(2); | |
score -= 10000; | |
// ok | |
} else { | |
if (br) fail(); | |
if (ct) fail(); | |
//counter(1); | |
score += 10000; | |
// ok | |
} | |
} else if (fr == 1) { | |
//counter(7); | |
if (iff) fail(); | |
if (br) { | |
//counter(3); | |
score += 10000; | |
} else { | |
//counter(5); | |
if (ct) { | |
score += 10000; | |
} else { | |
} | |
} | |
} else { | |
if (wh == 1) { | |
//counter(19); | |
if (br) { | |
if (ct) fail(); | |
if (iff) { | |
//counter(1); | |
score += 10000; | |
} else { | |
//score -= 10000; | |
} | |
} else { | |
if (ct) fail(); | |
if (iff) { | |
//score -= 10000; | |
} else { | |
score -= 10000; | |
} | |
} | |
} else { | |
//counter(1); | |
score -= 10000; | |
// ok | |
} | |
} | |
puts(score >= 0 ? "yes" : "no"); | |
} | |
p = ""; | |
} | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
main(){char*p="#include <stdio.h>%cmain(){char*p=%c%s%c,b[999];int i,j;sprintf(b,p,10,34,p,34);for(i=0;i<301;i++,putchar(10))for(j=300;j>=0;j--)putchar(b[j]);return 0;}",b[999];int i,j;sprintf(b,p,10,34,p,34);for(i=0;i<301;i++,putchar(10))for(j=300;j>=0;j--)putchar(b[j]);return 0;} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment