|
|
back to boardOH my god!!!!! Use vc++2010 or g++4.7.2 instead of G++4.7.2c++11 Posted by Pegasus 23 Apr 2013 18:45 When I use G++11 I always get TLE,but once I try vc++2010 to submit my code , I got AC. I wasted too much time.Any can expalin it for me ? This is my code:#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> const int MAXN = 1000000 + 10; int a[2 * MAXN]; using namespace std; int main() { int n; scanf("%d", &n); int i = 1; while (n--) { int t; scanf("%d", &t); if (t > 0) a[i++] = t; else if (t == -1) printf("%d\n", a[--i]); else if (t == 0) { if (i - 1 <= n) { int num = min(i - 1, n); for (int j = 1; j <= num; ++j) { a[i] = a[i-num]; ++i; } } } } //system("pause"); return 0; } Edited by author 26.04.2013 15:20 REALLY! Posted by BORODA 9 Dec 2013 21:06 MY LIFE WILL NEVER BE THE SAME! How does it works? could anybody explain it? Re: OH my god!!!!! Use vc++2010 or g++4.7.2 instead of G++4.7.2c++11 Apparently, printf is painfully slow in C++11 for some reason. I was having the same issue while trying to submit problem #1976 (where answer consists of up to 1000000 integers) and ended up implementing manual output via putchar. Now i know a simple change of language would've worked as well. Edited by author 10.12.2013 08:17 |
|
|