|
|
вернуться в форумPlease help: reading lines in C++ (+) What is the C++ *fast* analog for pascal's Readln? I used any of 3 methods: 1. cin.getline(vs1, MAX_STR_L); cin.getline(vs2, MAX_STR_L); 2. getline(cin, s1); getline(cin, s2); 3. while(..) {..scanf("%c", &c)..} Either of them is very slow (AC in 0.109), and running at my home PC shows that algo works *way* faster than reading input itself. So, someone who got AC in 0.015 in C++, please help. Edited by author 11.02.2006 18:50 Re: Please help: reading lines in C++ (+) Is scanf("%s",s1) also slow? AC in 0.031, thanks a lot! (-) - Edited by author 11.02.2006 19:51 Re: Please help: reading lines in C++ (+) Try this: #include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); // <- this line // Now synchronize I/O is off. With this line my programs works 0.001 (if algorithm is good enough ;-). |
|
|